Posted By: Anonymous
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.
chmod 600 pem file.
Then, this command
ssh -i /home/kashif/serverkey.pem [email protected]
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:
- Trying to connect with the wrong key. Are you sure this instance is using this keypair?
- Trying to connect with the wrong username.
ubuntuis the username for the ubuntu based AWS distribution, but on some others it’s
adminon some Debians, according to Bogdan Kulbida’s answer)(can also be
fedora, see below)
- Trying to connect the wrong host. Is that the right host you are trying to log in to?
1. will also happen if you have messed up the
/home/<username>/.ssh/authorized_keys file on your EC2 instance.
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
Use the ssh command to connect to the instance. You’ll specify the private key (.pem) file and [email protected]_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.