我想使用我的亚马逊ec2实例,但面临以下错误:

Permission denied (publickey).

我已经创建了密钥对并下载了.pem文件。

考虑到:

chmod  600 pem file.

然后,这条命令

ssh -i /home/kashif/serverkey.pem  ubuntu@ec2-54-227-242-179.compute-1.amazonaws.com

但是有这样的错误:

Permission denied (publickey)

另外,我如何连接filezilla上传/下载文件?


当前回答

我已经两次有正确的键和ssh命令行(我知道,因为我正在复制一个工作的Ubuntu 14.04实例),但就是不能ssh到一个新实例,即使在上面Wade Anderson建议的等待5分钟之后。

我必须摧毁并重新制造机器。这种情况已经发生过两次。因为一开始我进不去,我看不出有什么问题。

所以,如果你有这个问题,试试这个。

其他回答

我在Windows中使用WinSCP。它在文件资源管理器和PuTTY SSH Shell上都能很好地访问我的Amazon EC2-VPC Linux。chmod pem文件没有任何作用,因为它使用myfile。PuTTYgen将pem文件转换为ppk。

我挣扎着同样的权限拒绝错误显然是由于

key_parse_private2: missing begin marker 

在我的情况下,原因是当前用户的ssh配置文件(~/.ssh/config)。

使用以下方法:

ssh -i ~/myKey.pem ec2-user@<IP address> -v 'exit'

初步输出结果显示:

debug1: Reading configuration data /home/ec2-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Hostname has changed; re-reading configuration
debug1: Reading configuration data /home/ec2-user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config

…许多调试线在这里切断…

debug1: Next authentication method: publickey
debug1: Trying private key: /home/ec2-user/somekey.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.

上面的第三行是实际发现问题的地方;然而,我在调试消息从底部(上面)四行,并被误导。钥匙没有问题,但我测试了一下,比较了其他配置。

我的用户ssh配置文件通过一个意外的全局设置重置主机,如下所示。第一行Host不应该是注释。

$ cat config
StrictHostKeyChecking=no
#Host myAlias
        user ec2-user
        Hostname bitbucket.org
#        IdentityFile ~/.ssh/somekey
#        IdentitiesOnly yes

Host my2ndAlias
        user myOtherUser
        Hostname bitbucket.org
        IdentityFile ~/.ssh/my2ndKey
        IdentitiesOnly yes

我希望这对其他人有帮助。

这就是我解决问题的方法

ssh -i <key> ec2-user@<ec2 ip>

试着用

sudo ssh -i mykey.pem ubuntu@<ec2_ip_public_dns>

OR

sudo ssh -i mykey.pem ec2-user@<ec2_ip_public_dns>

我也为此挣扎了一段时间,直到我发现了以下几点:

eb ssh

当你从项目目录中使用它时,没问题,没问题,你就进入了