Use password to ssh into EC2 instances
1) First, login to your Ec2 instance
#ssh ec2-user@PUBLIC_IP_OF_EC2 -i THE_PEM_FILE.pem
2) Now access the root user by using the command $ sudo su
$ sudo su
We can verify whether have changed to the root user using the command whoami
# whoami
root
3) Now lets edit the configuration file in order to access the EC2 using a password
vim /etc/ssh/sshd_config
Now edit the exact lines mentioned in the configuration as seen in the below video
Note: In ubuntu based instances we need to change as below
PermitRootLogin yes
4) Once the edits are made save the file and restart the sshd service using the below commands
# service sshd restart
5) Now create a new user with a new password or update the existing EC2 user password and follow the traditional PASSWORD based SSH login to the server
# passwd username
New password:
Retype new password:
passwd: password updated successfully
5.1) Use the new password to access the server
$ ssh ec2-user@x:x:x:x
ec2-user@x:x:x:x's password:
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Mon Oct 19 07:30:15 2020 from x:x:x:x
Reference and need to add more: https://github.com/ValaxyTech/DevOpsDemos/blob/master/Ansible/Ansible_installation.MD