Q: When I create a new user in Red Hat, how can I force this user to change their password the first time they log on via ssh?
A: Using a few well known commands, we can make sure the user is forced to change their password upon first login. For this example we will use both the usermod command and the chage command.
Here are the three steps I would take to force a user to change their password on next login. For this example we will use your name as an example user account.
First we create the account:
useradd haden
Then we set a password for the account:
passwd haden
Then we force the password to expire:
usermod -L haden
chage -d 0 haden
usermod -U haden
This effectively locks the users password. Then we use the chage command the change the age of the password to 0 (forcing a password change), then we unlock the account allowing the user to log in with their old password one last time.
Anyone is welcome to post in the comments how they accomplish this same task. We love to hear different ways to accomplish the same task.
Helpful Links
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
4 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
passwd -f on Solaris
on CentOS when the user logins via ssh; everthing works, except they are disconnected after entering the new password once
On CentOS when the user login via ssh they get disconnected after entering the new password once
passwd -e haden