1849031 Members
4307 Online
104041 Solutions
New Discussion

Re: passwords

 
Angela Swyers_1
Frequent Advisor

passwords

I am setting up a new server. I want to set everyone's passwords back to something standard like 12345 and force them to change it the next time they log in. I know it's the -f to force a change, but how do I pass in the password without having to do wach one manually?
9 REPLIES 9
Sridhar Bhaskarla
Honored Contributor

Re: passwords

Hi Angela,

'/usr/sam/lbin/usermod.sam' will come in useful here. Once you added the users (You can use useradd command via a script), then do

1. Set one user with the standard password.
2. Grab the encrypted password from /etc/passwd or /tcb/files/auth//login file

#for user in $(cat your_user_list)
do
/usr/sam/lbin/usermod.sam -p "" $user
passwd -f $user
done

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Prashant Zanwar_4
Respected Contributor

Re: passwords

you may do something like below:

`awk -F: '{print $1}' /etc/passwd` >> /tmp/users.tmp
cat /tmp/users.tmp | while read users
do
echo $user: \c
passwd $user
passwd -f $user
done

It will ask you for password for all users in your system, you can discard using egrep -v "xx|xx..|xx"
or tail - or sed also has option to do it.
I dont see any option to pass the password to passwd command through some input.

Hope above helps
all the best
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Prashant Zanwar_4
Respected Contributor

Re: passwords

just the make correction, delete : \c, instead just let that be echo $user.

Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Govind_3
Regular Advisor

Re: passwords

Try to set the password for one user get the encrypted password. Lets say its "XXXXX".
For your own saftey make a backup of the password file and then use substitution s/:.*?:/XXXXX/g
this would change the password field for all the users.
-Goodluck
Govind
Prashant Zanwar_4
Respected Contributor

Re: passwords

In addition to above said by Govind:
do a pwconv after that, that should match all entries in password file and /tcb.

Hope above helps
Prashant
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."

Re: passwords

If you have a linux box with Expect on it, this will be trivial. Expect is a tool that automates inherently interactive processes.

Expect also comes with a tool called autoexpect which generates code (similar to Macro recording)
Franky_1
Respected Contributor

Re: passwords

Hi Angela,

i could think of something like :

for i in `cat /etc/passwd|awk -F: '{print $1}'`
do
passwd -d -f $i
done

Deletes PW for each user and forces hime to select a new one upon login

Regards

Franky
Don't worry be happy
Franky_1
Respected Contributor

Re: passwords

Hi Angela,

assigning points is also a good thing, btw :-)

I have assigned points to 8 of 104 responses to my questions.

Regards

Franky
Don't worry be happy
Muthukumar_5
Honored Contributor

Re: passwords

We can get standusers ( except system users like www etc ) as listusers | awk '{ print $1 }'


Your requirement can be done as,

for user in `listusers | awk '{ print $1 }'`
do

passwd -df $user
# Make a mail to user
echo "Null for passwd done on $user. You have to change it during login there" | mailx -s "passwd on `hostname` $user@yourdomain.com

done

We can not assign 12345 passwd to everybody there. For that we can keep them as NULL Passwd so that it will not be having passwd but during next login it will be asked to change the passwd.

Note: Assign points to your every post / reply there so that you will get response for your query at once. See franky message there.


HTH.
Easy to suggest when don't know about the problem!