Here are the steps to login into Ec2 instance without .pem file.
Login into Ec2 instance with .pem file.
$ ssh -i "aws-key.pem" firstname.lastname@example.org
Create a new user to access the Ec2 instance with strong password
$ sudo useradd USER_NAME $ passwd USER_NAME Changing password for user root. New password: BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic Retype new password: passwd: all authentication tokens updated successfully. $
Add the user to sudoers file visudo command and add the below line
USER_NAME ALL=(ALL) ALL
$ sudo visudo
Enable password authentication by editing /etc/ssh/sshd_config file.
# To disable tunneled clear text passwords, change to no here! #PasswordAuthentication yes #PermitEmptyPasswords no PasswordAuthentication no
Change to below configuration:
# To disable tunneled clear text passwords, change to no here! PasswordAuthentication yes #PermitEmptyPasswords no #PasswordAuthentication no
Comment for no and uncomment for yes
Restart sshd service.
# service sshd restart Redirecting to /bin/systemctl restart sshd.service #
Now, logout from the instance and login with your password.
$ ssh USER_NAME@ec2-35-154-198-16.ap-south-1.compute.amazonaws.com
It will ask for your password. Enter the password and hit Enter key.