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
Add following line
username ALL=(ALL) ALL
/etc/ssh/sshd_config setting and then set
PasswordAuthentication to yes. Open the vim or nano
sudo vim /etc/ssh/sshd_config
Find and set PasswordAuthentication to yes
Finally, restart the
sudo service ssh restart
sudo service sshd restart
Done, now you are able to login into your ec2 instance without the key pairs. Happy Hacking 🙂