How to Enable Password Authentication in AWS EC2 Instances


By default, the authentication is done using ssh keys. Enabling password authentication is a security loophole.

Step 1:

Login to AWS instances using ssh key

ssh -i your-key.pem username@ip_address

Step 2:

Setup a password for the user using passwd command along with the username.
My username that I want to enable is "himanshu"
sudo passwd himanshu

Step 3:

Edit sshd_config file.
sudo vi /etc/ssh/sshd_config

Find the Line containing 'PasswordAuthentication' parameter and change its value from 'no' to 'yes'
PasswordAuthentication yes

If you want to set up 'root' login, find  'PermitRootLogin' parameter and change its value from 'prohibit-password' to 'yes'
PermitRootLogin yes

After these changes save the file and exit.

Step 4:

Restart the SSH service.

service sshd restart           

or systemctl  sshd  restart

Step 5:

Now log in using the password you set for the user. 

ssh himanshu@34.56.4.4



If you like please follow and comment