Operating System - HP-UX
1823113 Members
3213 Online
109646 Solutions
New Discussion юеВ

password from command line

 
M. Tariq Ayub
Regular Advisor

password from command line

How can i cahnge password of diffreent user from command line in HP-UX 11i.

ie

passwd user1 password
passwd user2 password
10 REPLIES 10
Slawomir Gora
Honored Contributor

Re: password from command line

Hi,

you have to be logged as root to change password of other users.
syntax is:
passwd user1
and system will ask you for new password


lawrenzo
Trusted Contributor

Re: password from command line

procedure is -

su - root
passwd user
passwd -f user (force's the user to change passwd)

if your system is trusted you can reset the account and password by typing

/usr/lbin/modprpw -x user

hello
M. Tariq Ayub
Regular Advisor

Re: password from command line

I want to specify the new password from the command line. My system is not trusted. I need to cahnge 500 user password.
Patrick Wallek
Honored Contributor

Re: password from command line

You should take a look at using Expect to script this.

There is really no other way that I know of via the shell to do this.
Ravi_8
Honored Contributor

Re: password from command line

Hi,

If the users already exist then

#cat /etc/passwd |awk -F: '{print $1}' > file

for i in 'cat file'
do
passwd $i
done
never give up
M. Tariq Ayub
Regular Advisor

Re: password from command line

i want to provide the password by myself
hp admin
Frequent Advisor

Re: password from command line

Hello Tarik,

You can use this command, and note that even if /usr/sam/lbin/useradd.sam is a symbolic link to /usr/sbin/useradd, you cannot use this last command.

/usr/sam/lbin/useradd.sam -g users -d /home/username -c "comment of user" -s /usr/bin/ksh -p pass_of_user -o -u 104 user_name

Note the -p option, which with you can precise the password, but the problem is that exactely the word given will be saved on the passwd file (ie: not encrypted).

BONNAFOUS Jean Marc
Trusted Contributor

Re: password from command line

Hi,

Like Patrick say, you must use expect. With Expect you can 'convert' interactive command like passwd to 'automatic'.

Rgds
JMB
Si vous ne faites jamais de b├йtises, c'est que vous ne faites rien de difficile. Et ├зa c'est une grosse b├йtise.
B. Hulst
Trusted Contributor

Re: password from command line

Hi,

And make sure that if you script the "passwordchanger.ksh" you keep the script with passwords in a safe place with filepermissions that only root can see its content and change it.

Regards,
Bob
A. Clay Stephenson
Acclaimed Contributor

Re: password from command line

The easist method is to use Perl. You can use the getpwent() function to read each entry, call the crypt() function to create the new passwd hash and then write the entry out to another file. When you are finished copy the new file to /etc/passwed and you are set.
If it ain't broke, I can fix that.