Thursday, 19 April 2018

How to Setup Password Authentication For AWS ec2 Instances

Step 1: Login to the server using ssh client of your choice using the private key. For windows machines, you can use putty for connecting to the instance.
If you are using Mac or Linux, you can use the following command to connect to the instance.


ssh -i your-key.pem username@(public-ip-address)

Step 2:  Open sshd_config file.

sudo vi /etc/ssh/sshd_config


Step 3:  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“

After the changes, save the file and exit.


Step 4: Setup a password for the user using “passwd” command along with the username.  You need to enter the password twice. For example, if you want to set up a password for “ubuntu“, use the following command.

sudo passwd ubuntu


Step 5: Now, restart the “sshd” service using the following command.

sudo service sshd restart


Step 6: Now you can log out and log in using the password you set for the user. For example,

ssh ubuntu@(public-ip-address)

No comments:

Post a Comment