SSH to AWS EC2 instance without key pairs

This is a common issue for the developers to access ec2 instances by username and password authentication.  It requires a few steps to do that.

First, login as root using the key pairs.
Second, create a user

sudo adduser username

Third, you need to grant root level permission to the new user

visudo

Add following line

username ALL=(ALL) ALL

Forth, edit /etc/ssh/sshd_config setting and then set PasswordAuthentication to yes. Open the vim or nano

sudo vim /etc/ssh/sshd_confg

Find and set PasswordAuthentication to yes

PasswordAuthentication yes

Finally, restart the ssh daemon

For Ubuntu

sudo service ssh restart

For CentOS

sudo service sshd restart

Done, now you are able to login into your ec2 instance without the key pairs.  Happy Hacking 🙂

 

Eftakhairul Islam

Hi, I'm Eftakhairul Islam, a passionate Software Engineer, Hacker and Open Source Enthusiast. I enjoy writing about technical things, work in a couple of startup as a technical advisor and in my spare time, I contribute a lot of open source projects.

 

Leave a Reply

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

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Read previous post:
Upgrade PHP from 7.0 to 7.2

A long ago, I wrote about how to upgrade to 7.0. PHP 7.2 is released. Now, it's the time again...

Close