SSH login on EC2 Linux without .pem file?

By default one has to use a .pem file to SSH into a Amazon linux instance. This is a pretty good idea, and safer than a password. But sometimes it’s more practical to use a username and password.  You still can, this is how:

ssh-add-ec2V2-620x264

Add your downloaded .pem file to you ssh store on Linux and Unix systems like OS X:

ssh-add /path/to/pemfile.pem

Login without .pem file? Follow these steps:

  1. login using your .pem file (ssh -l pemfilename.pem ubuntu@publicip (or instancename.availabilityzone.compute.amazonaws.com)
  2. Create a new user to be used to login with a password (sudo useradd -s /bin/bash -m -d /home/adminbert -g root adminbert)
  3. Set a strong password (sudo passwd adminbert)
  4. configure SSH by editing the config file. Change this PasswordAuthentication from no to yes (sudo nano /etc/ssh/sshd_config)
  5. Restart SSH (sudo service ssh restart)

You can now login using a username and password.

(ssh username@publicipaddress / or username@instancename.availabilityzone.compute.amazonaws.com))

Leave a Reply