本文介绍了权限被拒绝(公钥)时,SSH访问Amazon EC2实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的Amazon EC2实例,但面临以下错误:

I want to use my Amazon ec2 instance but faced the following error:

Permission denied (publickey).

我已经创建了我的密钥对和下载质子交换膜文件。

由于:

chmod  600 pem file.

然后,此命令

Then, this command

 ssh -i /home/kashif/serverkey.pem  [email protected]

不过,有这样的错误:

But have this error:

          Permission denied (publickey)

此外,我怎么能与FileZilla的连接上传/下载文件?

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:

  1. 在试图与错键连接。你确定这个实例使用该密钥对?
  2. 在试图用错误的用户名进行连​​接。 的Ubuntu 是用户名Ubuntu的基于AWS分布,但对另一些人是 EC2用户(或管理​​一些Debians,根据波格丹Kulbida的答案)(也可以是的Fedora ,见下文)
  3. 在尝试连接错误的主机。是正确的主机,你正在试图登录?
  1. Trying to connect with the wrong key. Are you sure this instance is using this keypair?
  2. Trying to connect with the wrong username. 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)
  3. Trying to connect the wrong host. Is that the right host you are trying to log in to?

注意 1 也会发生,如果你搞砸了 /家庭/<用户名> / SSH / authorized_keys中您的EC2实例文件。

Note that 1. will also happen if you have messed up the /home/<username>/.ssh/authorized_keys file on your EC2 instance.

关于 2 ,哪些用户名应该使用往往是从AMI图片说明缺乏信息。但是你可以找到一些在AWS EC2文档,圆点 4 :http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

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

使用ssh命令连接到该实例。你会指定私钥(质子交换膜)文件,用户名@ public_dns_name。对于Amazon Linux中,用户名为EC2用户。对于RHEL5,用户名称是根或 EC2用户。对于Ubuntu的,用户名是的Ubuntu 。对于Fedora的,用户名可以是的Fedora EC2用户。对于SUSE Linux,用户名是。否则,如果EC2用户和根不工作,请与您的AMI供应商。

最后,要知道,还有很多其他的原因,身份验证会失败。 SSH通常是pretty的明确一下,如果你愿意的 -v 选项添加到您的SSH命令,并读取输出,因为在许多其他的答案来解释什么地方出了错这个问题。

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.

这篇关于权限被拒绝(公钥)时,SSH访问Amazon EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 05:22