I’m trying to force a newly created user to change a password at the first time login using ssh. For security reasons I want to give him a secure password until he logs in for the first time. I did the following so far:
useradd -s /bin/bash -m -d /home/foo foo passwd foo
Doing chage -d 0 foo only gives me the the error Your account has expired; please contact your system administrator on ssh login.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
change the age of password to 0 day
syntax chage -d 0 {user-name}
In this case
chage -d0 foo
This works for me over ssh also
Method 2
Depending on the version passwd you can try
-
passwd -f: Forces the user to change password at the next login by expiring the password for name. -
passwd -eorpasswd --expire: Immediately expire an account’s password. This in effect can force a user to change his/her password at the user’s next login.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0