Published August 17, 2018 by

How to Enable Password Authentication in AWS ec2 Instances

Please Note this article is only for information and practice. Please don't do this until you have any specific and valid reason. Because it's a big security hole by opening direct root access and enable password authentication of the server in the cloud.

By default, AWS ec2 instances don’t have password authentication. You have to use the private key to connect to the instances. However, you might have situations to use password-based authentication for your AWS ec2 instances.

In this tutorial, we have done the configuration to enable password authentication in AWS instance.

Step 1:

Login to AWS instances
ssh -i your-key.pem username@ip_address

Step 2:

Setup a password for the user using passwd command along with the username.
sudo passwd ubuntu

Step 3:

Edit sshd_config file.
sudo vim /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 this changes save file and exit.

Step 4:

Restart the SSH service.

service ssh restart                                  ## for ubuntu

service sshd restart                                ## for centos

Step 5:

Now we can log in using the password you set for the user. For example,
ssh ubuntu@