amazon-web-servicesubuntuamazon-ec2sshcentos

How to access SSH of AWS EC2 Instance(ubuntu) without pem file


I tried a solution but that doesn't work.

  1. Login into your instance with the .pem file
  2. cd / (just incase)
  3. Edit, vim /etc/ssh/sshd_config and edit PasswordAuthentication yes
  4. Restart sshd service, service sshd restart or systemctl restart sshd or equivilent
  5. Set password, passwd - (user : ubuntu)
  6. Log out and log back in without .pem file ssh root@{public IP}

After then, I tried ssh ubuntu@{public IP} , I got ubuntu@{public IP}: Permission denied (publickey) and I checked a debug too

...
debug1: Trying private key: C:\\Users\\{User}/.ssh/id_dsa
debug3: no such identity: C:\\Users\\{User}/.ssh/id_dsa: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
ubuntu@{public IP}: Permission denied (publickey)

I couldn't access. I think it's still find pem file.

So How could I access without pem file?


Solution

  • Looks like you don't have your local PC keypair needed for ssh handshake.

    Try to generate it on your PC, and login again:

    ssh-keygen -o