Operating System - HP-UX
1752720 Members
6045 Online
108789 Solutions
New Discussion юеВ

how to change password using usermod

 
SOLVED
Go to solution
chakribobby
Advisor

how to change password using usermod

hi
how to give an crypt password for "usermod -p" such that i can change the password for the given user
thanks in advance
7 REPLIES 7
Hasan  Atasoy
Honored Contributor

Re: how to change password using usermod

hi ;

assume that you will change user user1 and password will be pass1

crypt pass1 | read newpass
usermod ${newpass} user1

or

usermod `crypt pass1` user1

Hasan.
please assign points.
chakribobby
Advisor

Re: how to change password using usermod

i am unable to get the $ prompt after running the command
can you give me the correct syntax for that command
Hasan  Atasoy
Honored Contributor

Re: how to change password using usermod

sorry;
I forgot to write -p option.


usermod -p `crypt pass1` user1


hASAN
chakribobby
Advisor

Re: how to change password using usermod

now also i am unable to get the $ prompt of running the command i have to use ctrl+c to get
$ prompt
bash-3.2# usermod -p `crypt pass1` aa





Kasper Hedensted
Trusted Contributor

Re: how to change password using usermod

I think that you need to use the "usermod.sam" file:

/usr/sam/lbin/usermod.sam -p "3dt14Ul7TWS.U" username


regards,
Kasper
chakribobby
Advisor

Re: how to change password using usermod

how can i convert my password in to the encrypted formate

the key for encryption must match the key of the system?


if i use this
usermod -p with key 123> username

then the password for the user is changed

but when i used my
i am unable to log in

A. Clay Stephenson
Acclaimed Contributor
Solution

Re: how to change password using usermod

The crypt command will not work for this. The algorithm is different but the Perl crypt function will work. (Don't panic you don't have to know any Perl.)

#!/usr/bin/sh

typeset -i STAT=0

typeset SALT="Q9"
typeset PLAINTEXT="secret"
typeset HASH=$(perl -e "print crypt(${PLAINTEXT},${SALT})")
STAT=${?}
echo "Password Hash = \"${HASH}\""
exit ${STAT}

Note: With a little more effort you could use a randomly generated salt rather than the fixed "Q9" in this example. Man 3 crypt to understand what "salt" does.


If it ain't broke, I can fix that.