Trying to SSH into an Amazon Ec2 instance - permission error

后端 未结 29 3511
一生所求
一生所求 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:25

    Well, looking at your post description I feel there were 2 mistakes done by you:-

    1. Set correct permissions for the private key. Below command should help you to set correct file permision.

      chmod 0600 mykey.pem

    2. Wrong ec2 user you are trying to login.

      Looking at your debug log I think you have spawned an Amazon linux instance. The default user for that instance type is ec2-user . If the instance would have been ubuntu then your default user would have been ubuntu .

      ssh -i privatekey.pem default_ssh_user@server_ip

    Note:
       For an Amazon Linux AMI, the default user name is ec2-user.
    
       For a Centos AMI, the default user name is centos.
    
       For a Debian AMI, the default user name is admin or root.
    
       For a Fedora AMI, the default user name is ec2-user or fedora.
    
       For a RHEL AMI, the default user name is ec2-user or root.
    
       For a SUSE AMI, the default user name is ec2-user or root.
    
       For an Ubuntu AMI, the default user name is ubuntu.
    
       Otherwise, if ec2-user and root don't work, check with the AMI provider.
    

    source: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

提交回复
热议问题