How To Enable Password based Authentication in SSH

Password-based authentication is a more secure way of logging into SSH and offers better protection against malicious attacks. However, password authentication in SSH is disabled by default. In this article, we will look at how to enable password based authentication in SSH.


How To Enable Password based Authentication in SSH

Here are the steps to enable password based authentication in SSH. Before proceeding, please ensure your Linux user has a password in place. If not, then log into SSH as root and use the following command to set password for your Linux user. Replace $username with your username and enter new password when prompted.

$ sudo passwd $username 
Changing password for user $username. 
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.


1. Edit sshd_config

Open sshd_config file in a text editor

$ sudo vi /etc/ssh/sshd_config

Also read : How to Enable Multifactor Authentication in SSH


2. Enable password authentication

Look for PasswordAuthentication no and replace no with yes

PasswordAuthentication no

Save and close the file.

If you want to disable password authentication, just change PasswordAuthentication to no again.

Also read : How to Enable IPv6 in Linux


3. Restart SSH

Restart SSH server to apply changes.

$ sudo /etc/init.d/sshd restart

Now when users log into SSH, they will be prompted for password.

Leave a Reply

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