Default Linux/CentOS EC2 AMI comes with Password authentication disabled for obvious security reasons. To enable this, follow the below-given steps.

Step#1 Edit the ssh configuration file


Open the ssh configuration file in vi editor

Code:
vi /etc/ssh/sshd_config
Go to the line containing PasswordAuthentication
Code:
#PasswordAuthentication yes
Uncomment the line
Code:
PasswordAuthentication yes
Save and come out of vi editor.

Step#2 Reload ssh configuration file


Code:
systemctl reload sshd.service
This would work in RHEL8,7 and CentOS 8 and 7. Older version of Linux, restart using service sshd reload

Step#3 Open AWS Firewall for port 22


In your EC2 instance Security group(SG), add ssh port 22 in inbound rule.

Now, you should be able to login to your Linux instance using a username and password!