AWS will disable the preconfigured password that was previously configured when launching an instance from AMI. To keep the password active so that it can be login using username & password immediately upon launching it from image, lock_passwd needs to be set to false.
Let’s start from the beginning. Login EC2 with key.
Enable SSH login by password by editing the ssh config file
sudo vim /etc/ssh/sshd_config