How to Set Up and Change SSH Password

In UNIX platform, a password for SSH does not exists, a separate user-id and password is not required to login to a remote system, it uses the user account details of the UNIX system itself. In this tutorial we will guide you on how to set up and change the ssh password in Linux.

Step#1: Setup an SSH password
If we open up the terminal application and try connecting to the local host using the root user, an error would appear stating that the permission is denied. That is because by default SSH disables root login as a security measure.
That means, to setup a password for ssh for the root user, we would have to edit the ssh configuration file.
For that, we will open up the ssh configuration file in the graphical editor using the command:
gedit /etc/ssh/sshd_config
In the configuration, move to the authentication section and change the value for Permit Root Login from no to yes. With that done, you can close the editor window and get back to the terminal.
creating an SSH password for root

Step#2: SSH login with password
Over here, let’s restart the ssh service for the changes to take effect.
Now let’s try to connect to the local host as the root user and you would notice that a new session will be created with the root user. That means the ssh password has been successfully configured.
login with the new password

Step#3: Change password
To change the ssh password, you can simply change the password of the username you are connecting with. Since we are logged in as the root user, we will type
sudo passwd followed by the username, which in this case is root.
editing the password

Step#4: Update new password
With that done, you can now type the new password which you want to keep. Next, you would be required to re-type the password as a security check.
Once done, the password would be successfully changed.
And that’s it.
entering the new password