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.


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


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 -e or passwd --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.

  • passwd -e changes the login shell. – schily Feb 11 '16 at 11:11
  • 2
    passwd -e works for me (Linux Mint 17.3) – Joril May 16 '17 at 7:52
  • passwd -e works in RHEL 7.0 – Crypteya Apr 23 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.