Short tip: Reset Linux password unattended

Download PDF

Sometimes it happens that you lock out yourself from your Linux system. In the worst case, additional security concepts or conditions might hamper access to the system, for example:

  • No root access
  • System cannot be rebooted to reset the password in a chroot session
  • No colleague with system access available

Recently I had an issue like this – but happily the system was still controllable by a central configuration management. I was able to run the following commands to reset the password:

# echo "username:password" | chpasswd
# chage -d 0 username

The first command defines the username and the new password and hands it to chpasswd. The second command forces the user to change his password right after the next login. Depending on the flavor of configuration management, it might be possible to see the script in plain text in the system’s history. So – you really should change the password as soon as possible.

Download PDF