| |

How to Change Linux Account Password Through SSH: A Beginners’ Tutorial

Changing Your Password Over SSH

When you first get SSH access to a Linux system, you’ll typically need to change your initial password. The process is straightforward once you know the steps.

Connect via SSH

Open a terminal and connect to the server:

ssh USER@HOST

Replace USER with your username and HOST with the server’s hostname or IP address.

If this is your first time connecting to this host, SSH will ask if you trust it:

The authenticity of host 'HOST (IP_ADDRESS)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Type yes and press Enter. SSH will then prompt for your password:

USER@HOST's password:

Enter your current password. Note that characters won’t display as you type—this is normal behavior.

Change Your Password

Once logged in, run the passwd command:

passwd

You’ll see output like:

Changing password for user USER.
(current) UNIX password:

Enter your current password again. Then:

New password:

Type your new password. Again, you won’t see what you’re typing. Then:

Retype new password:

Enter the new password a second time to confirm. If the passwords match, you’ll see:

passwd: all authentication tokens updated successfully.

This confirms the change worked.

Exit SSH

Disconnect from the server:

exit

Or use Ctrl+D.

Practical Tips

Use strong passwords: Aim for at least 12 characters mixing uppercase, lowercase, numbers, and symbols. Many systems enforce complexity requirements that passwd will reject weak passwords.

Test your new password: Before closing your terminal, open a new SSH session to verify the new password works:

ssh USER@HOST

SSH keys are better: For regular access, consider setting up SSH key-based authentication instead of passwords. This eliminates the need for password changes and is more secure:

ssh-keygen -t ed25519
ssh-copy-id -i ~/.ssh/id_ed25519.pub USER@HOST

Password expiration: Some systems require periodic password changes. Check your organization’s policy and your current settings:

chage -l

This shows password aging information for your account.

Stuck with an expired password? If your password has expired and SSH won’t let you in, contact your system administrator. You may need to use a different authentication method or have them reset your account temporarily.

Similar Posts

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *