Permission denied (publickey) when SSH Access to Amazon EC2 instance
I want to use my Amazon ec2 instance but faced the following error:
Permission denied (publickey).
I have created my key pair and downloaded .pem file.
Given:
chmod 600 pem file.
Then, this command
ssh -i /home/kashif/serverkey.pem ubuntu@ec2-54-227-242-179.compute-1.amazonaws.com
But have this error:
Permission denied (publickey)
Also, how can I connect with filezilla to upload/download files?
This error message means you failed to authenticate.
These are common reasons that can cause that:
ubuntu
is the username for the ubuntu based AWS distribution, but on some others it's ec2-user
(or admin
on some Debians, according to Bogdan Kulbida's answer)(can also be root
, fedora
, see below) Note that 1.
will also happen if you have messed up the /home/<username>/.ssh/authorized_keys
file on your EC2 instance.
About 2.
, the information about which username you should use is often lacking from the AMI Image description. But you can find some in AWS EC2 documentation, bullet point 4.
: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
Use the ssh command to connect to the instance. You'll specify the private key (.pem) file and user_name@public_dns_name. For Amazon Linux, the user name is ec2-user. For RHEL5, the user name is either root or ec2-user . For Ubuntu, the user name is ubuntu . For Fedora, the user name is either fedora or ec2-user . For SUSE Linux, the user name is root . Otherwise, if ec2-user and root don't work, check with your AMI provider.
Finally , be aware that there are many other reasons why authentication would fail. SSH is usually pretty explicit about what went wrong if you care to add the -v
option to your SSH command and read the output, as explained in many other answers to this question.
In this case the problem arises from lost Key Pair. About this:
You can follow these steps:
In general, remember you have to allow your EC2 instance to accept inbound SSH traffic.
To do this, you have to create a specific rule for the Security Group of your EC2 instance. You can follow these steps.
Hope this can help someone as helped me.
这就是我解决问题的方法
ssh -i <key> ec2-user@<ec2 ip>
链接地址: http://www.djcxy.com/p/32440.html
上一篇: EC2实例没有公共DNS