How to change user's password from shell ?

General support questions including new installations

How to change user's password from shell ?

Postby Technologov » 2012/01/12 01:19:56

NOTE: Tricky question, for Advanced Linuxoids only !

hi,
how can I create encrypted passwords from shell script ?
in Debian "mkpasswd" does this job, but not so for Red Hat...

In Debian, when I write shell, I can change user's password, like this:
usermod -p $(mkpasswd -s $password) $user

I'm trying to find equivalent in Red Hat.

I did "man usermod" and "man adduser" but both require encrypted password.
Notice: "mkpasswd" command does *exist* in Red Hat (part of "expect"), but is completely different from Debian's... so I'm stuck.

Any ideas?

Thanks in advance,
-Technologov
Technologov
 
Posts: 1
Joined: 2012/01/12 01:14:10

Re: How to change user's password from shell ?

Postby TrevorH » 2012/01/12 02:12:39

Does this work?

Code: Select all
$ echo password | openssl passwd -crypt -stdin
wBTin4MUnz.Qk
User avatar
TrevorH
Forum Moderator
 
Posts: 9166
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

How to change user's password from shell ?

Postby r_hartman » 2012/01/13 10:25:45

Technologov wrote:
I did "man usermod" and "man adduser" but both require encrypted password.

man passwd

Not sure if this is what you're looking for, but
Code: Select all
echo password | passwd --stdin
would allow you to change passwords from a script.
r_hartman
 
Posts: 701
Joined: 2009/03/23 15:08:11
Location: Netherlands


Return to CentOS 5 - General Support

Who is online

Users browsing this forum: No registered users and 4 guests