Normally, when create an ec2 or a lightsail we want to choose a key to launch instance, key login is very secure , no one can login to server without the keys, but when we lost the keys then even we can't login to server. So here we are doing how we can login to server with ssh password instead of keys.
Method 1
step 1 : Create an ec2 instance in aws with linux ami by specify a key and login to server with that keys using putty.
login as root and change root password
sudo /bin/bash
passwd
and give new password

Step 2: Open the sshd_config
file and find PasswordAuthentication parameter and change its value from “no” to “yes” , Then PermitRootLogin value to yes.
vi /etc/ssh/sshd_config
press "i" to insert mode and edit , for saving, ESC (to exit insert mode) and SHIFT + :wq

Step 3: Now, restart the “sshd” service using the following command.
sudo service sshd restart
Thats all. Now try login to ec2 with root username and password.
Method 2
Here we can all automate this. We are going to launch an ec2 instance with a bash script and specify it as userdata.
change your password instead of '123'
#!/bin/bash
sed -i '38 i PermitRootLogin yes' /etc/ssh/sshd_config
sed 's/PasswordAuthentication no/PasswordAuthentication yes/' -i /etc/ssh/sshd_config
service sshd restart
echo "123" | passwd --stdin root

Thats all. Try login with your password