Operating System - Linux
1829426 Members
3845 Online
109991 Solutions
New Discussion

How to force password change at 1st login?

 
Debbie Fleith
Regular Advisor

How to force password change at 1st login?

I have a whole list of users to add to a new Red Hat 7.2 system and I want to add them without a password, or a temporary one, and have the system prompt them for a new login at 1st login time.

Anyone know how to do this?
8 REPLIES 8
Sachin Patel
Honored Contributor

Re: How to force password change at 1st login?

use -f options when you setup his/her temporary passwd.

for example you setup blanck password on /etc/passwd file then
#passwd -f sachin
newpasswd:*****
newpasswd:****

now when user sachin logs on with temporary passwd system will ask him to change his passwd.

-f This option forces the user to enter a new password on the next login.

Sachin
Is photography a hobby or another way to spend $
Debbie Fleith
Regular Advisor

Re: How to force password change at 1st login?

I tried passwd -f, it did not work. Does that only work if you select a particular shell for the user?
Stuart Browne
Honored Contributor

Re: How to force password change at 1st login?

No limitations of shell from the documentation I can see. It should be done at the LOGIN level (which is what spawns the shell).

What 'shell' are you using?
One long-haired git at your service...
Debbie Fleith
Regular Advisor

Re: How to force password change at 1st login?

I've tried /bin/bash and /bin/sh
Sachin Patel
Honored Contributor

Re: How to force password change at 1st login?

Are you using this in NIS?

Sachin
Is photography a hobby or another way to spend $
Debbie Fleith
Regular Advisor

Re: How to force password change at 1st login?

No, NIS.

I've just tried adding users with useradd, and through GNOME's interface.
MAD_2
Super Advisor

Re: How to force password change at 1st login?

Conform to a local standard for first time logins. Let's say you create and id temp and give it the password id+random number, i.e. temp3991, so you give all your initial accounts a password with pattern id3991. Then tell the user what the password will be and that it will be prompted to change it on the first login (users should be aware that they will be prompted for the new password twice).

For the system to prompt for a new password at first login, the -f option should work:

# passwd -f temp3991
#

The user will login like this
login: temp
passwd: ######## (say temp3991)
new passwd: ########
new passwd: ########

Hope this helps!
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Stuart Browne
Honored Contributor

Re: How to force password change at 1st login?

*blinks*

*finds a 7.2 box*

*tests*

ugh..

*reads documentation again*

ugh..

*plays some more*

ugh!

Ok.
1) passwd -f is NOT force user to change a next login. the '-f' flag under RH7.2 is for foricbly unlocking an account which has only an '!' in the password field.

2) Changing the "Password expires in" x "days" field to 0 doesn't force it to change the password now.

3) I'm having a bad morning :(

After reading through far too many man pages in a morning than could possibly be good for a person, I'm having to admit that you'll probably need a scripted solution in order to achieve this goal, or find a utility on the 'net that will do it for you (possibly a PAM plugin).

Unfortunately, I was unable to find such a thing in a quick 10 minute search.

Sorry.
One long-haired git at your service...