The default user for Amazon Linux 2 is ec2-user, first, we need to create a password for the ec2-user
[ec2-user@ip-164 ]$ sudo passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Then enable the password authentication for the Login in the SSHD config file
sudo nano /etc/ssh/sshd_config
Find the PasswordAuthentication no
and set it to yes
Restart the SSHD Service
sudo systemctl restart sshd
Also published on Medium.