Trying to SSH into an Amazon Ec2 instance - permission error

后端 未结 29 3277
一生所求
一生所求 2020-11-27 08:51

This is probably a stupidly simple question to some :)

I\'ve created a new linux instance on Amazon EC2, and as part of that downloaded the .pem file to allow me to

相关标签:
29条回答
  • 2020-11-27 09:34

    The problem is having wrong mod on the file.

    Easily solved by executing -

    chmod 400 mykey.pem

    Taken from Amazon's instructions -

    Your key file must not be publicly viewable for SSH to work. Use this command if needed: chmod 400 mykey.pem

    400 protects it by making it read only and only for the owner.

    0 讨论(0)
  • 2020-11-27 09:35

    Take a look at this article. You do not use the public DNS but rather the form

    ssh -i your.pem root@ec2-XXX-XXX-XXX-XXX.z-2.compute-1.amazonaws.com
    

    where the name is visible on your AMI panel

    0 讨论(0)
  • 2020-11-27 09:35

    ssh -i /.pem user@host-machine-IP

    I think it's because either you have entered wrong credentials or, you are using a public key rather than private key or, your port permissions are open for ALL to ssh. This is bad for Amazon.

    0 讨论(0)
  • 2020-11-27 09:37

    Ok man, the only thing that worked for me was:

    1. Change permissions of the key

      chmod 400 mykey.pem

    2. Make sure to log in using ec2-user, and the correct ec2-99... address. The ec2-99 address is at the bottom of the aws console when you're logged in and seeing your instance listed

      ssh -i mykey.pem ec2-user@ec2-99-99-99-99.compute-1.amazonaws.com

    0 讨论(0)
  • 2020-11-27 09:38

    Checklist:

    1. Are you using the right private key .pem file?

    2. Are its permissions set correctly? (My Amazon-brand AMIs work with 644, but Red hat must be at least 600 or 400. Don't know about Ubuntu.)

    3. Are you using the right username in your ssh line? Amazon-branded = "ec2-user", Red Hat = "root", Ubuntu = "ubuntu". User can be specified as "ssh -i pem usename@hostname" OR "ssh -l username -i pem hostname"

    0 讨论(0)
提交回复
热议问题