Enable SSH Password Authentication

Most major cloud providers such as AWS, OCI, Google Cloud, disable SSH password authentication method by default, allowing the users to only use private/public key pair for authentication. Even though using private/public keys is much safer method, some time you may need to be able to access your server using username and a password. To enable SSH password authentication, you need to make a few changes to the SSH server configuration file. Here’s a step-by-step guide:

Connect to your SSH server as a user with administrative privileges. This can be done either by logging in directly or using a remote management tool like SSH or PuTTY. To connect with ssh run the commend below in your terminal window.

ssh -i PATH/TO/PRIVATE.KEY USER@SERVER_ADDRESS

Once connected to your server, open the SSH server configuration file “sshd_config”. The location may vary depending on the operating system you are using, in most linux distributions it is located in “/etc/ssh/”. To open the file with nano run the following command.

nano /etc/ssh/sshd_config

To allow password authentication globally for all users (NOT RECOMMENDED!). In “sshd_config” Search for the line that begins with “PasswordAuthentication”. If password authentication is disabled, it will be set to “no”. To enable password authentication all you need to do is change the value to “yes”. Save and close the file, then restart your ssh service by running the following command.

service ssh restart

To only allow password authentication for specific user (RECOMMENDED!). Leave the “PasswordAuthentication” directive set to “no”. Go to the bottom of “sshd_config” file and add the following two lines.

Match User USERNAME_HERE
    PasswordAuthentication yes

Save and close the file, then restart your ssh service by running the following command.

service ssh restart

This will make an exception to the global SSH configuration and it will enable password authentication for the listed user.

To see this tutorial in action check out my video tutorial on YouTube!