How to force user to change password on next login in Linux 2022

0

This tutorial explains how to force user to change password on next login in Linux. We will do our best for you to understand this guide. I hope you will like this blog How to force user to change password on next login in Linux. If your answer is yes, please share after reading this.

Check how to force user to change password on next login in Linux

How can I force my Linux users to change their passwords on first login on CentOS/Debian Linux? How can I ensure that the user changes the passphrase the next time they connect to the Linux server? You can use one of the attached commands to change user passwords on first login:

Force user to change password using passwd command

The passwd command is mainly used to assign or change a user’s password on a Linux system. For example, to reset the password for a user named bob, simply run the following command as the root user:

password bob

You will be prompted to provide a new password for the user account and then confirm it as instructed. In addition to setting or changing a user’s password, the passwd command can also be used to force the user to change the password on their next login attempt. This is possible using the provided syntax.

password -e

The -e option (also expressed as –expire) simply causes the user account password to expire and forces the user to change the password at next login. For example, to remove Bob’s password, just run the command

password -e bob

OR

passwd – expire bob

Then you can check the password aging or expiration information by running the chage command as shown.

switch -l bob

From the output, we can clearly see that user bob’s password needs to be changed on next login. On the next login attempt, user bob will receive a notification that his password has expired and must be changed before continuing. The user will first need to provide the previously used password, then enter the new password, then confirm it as shown below.

Force user to change password using chage command

As we did earlier, the chage command provides information about the user’s age. You can also use the command to expire a user’s password and force them to change it the next time they log in.

You can achieve this by using the -d option followed by 0, which implies day zero. Additionally, you can use the –lastday flag which specifies the number of days since the epoch (January 1, 1970). Syntaxes are provided below.

change -d 0

OR

change – last day 1970-01-01

For example, you can expire a user named jack as shown.

change -d 0 jack

Final Words: How to Force User to Change Password on Next Login in Linux

Hope you understand this article How to force user to change password on next login in Linux, if your answer is no, you can ask anything via the contact forum section linked to this article. And if your answer is yes, share this article with your family and friends.

Share.

Comments are closed.