You are not logged in.

#1 2018-02-21 14:46:15

2XEKmkZd4C6PeYdgmuiHL6xaj
Member
Registered: 2018-02-21
Posts: 20

[SOLVED] How to change login password in BASH script?

I found 

 # echo "somewords" | passwd --stdin username

won't work. So what should be used instead of that option "--stdin " ? Or do you have any other way of doing it?

Last edited by 2XEKmkZd4C6PeYdgmuiHL6xaj (2018-02-21 15:09:29)

Offline

#2 2018-02-21 14:53:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] How to change login password in BASH script?

Where did you get "--stdin" from?  passwd reads from stdin by default.  But you do need to enter the password twice.  I don't know if this is the best way, but this works:

printf "somewords\nsomewords\n" | passwd username

Actually there is a tool specfically for scripted password changes: `chpasswd`.  Use that:

echo username:somewords | chpasswd

Last edited by Trilby (2018-02-21 14:55:46)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-02-21 15:07:23

2XEKmkZd4C6PeYdgmuiHL6xaj
Member
Registered: 2018-02-21
Posts: 20

Re: [SOLVED] How to change login password in BASH script?

Thanks a lot.

Offline

Board footer

Powered by FluxBB