我想使用我的亚马逊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上传/下载文件?


当前回答

您需要执行以下步骤:

如果您使用的是Linux,请打开ssh客户端或终端。 找到您的私钥文件并更改目录。 CD <您的。pem文件>的路径 执行以下命令: Chmod 400 <filename>.pem SSH -i <filename>。pem ubuntu@ < ipaddress.com >

如果ubuntu用户无法使用,那么尝试使用ec2-user。

其他回答

当你尝试

SSH -i <。Pem路径> root@ec2-public-dns

您将收到一条消息,建议您使用ec2用户。

请以“ec2-user”用户而不是“root”用户登录。

所以使用

SSH -i <。Pem路径> ec2-user@ec2-public-dns

试着用

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

OR

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

以我自己为例,我做了以下事情:

chmod 400 <key.pem>

ssh -i <key.pem> ec2-user@ec2_public_dns (for debian)

我最初使用root@部分,我得到了这个提示:

Please login as the user "ec2-user" rather than the user "root".

我也犯过类似的错误

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: xxxx.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我的问题是,由于第3步的run-on- startup脚本上的错误,实例没有正确启动:在高级详细信息下配置实例详细信息:

我心里想的是:

# include
 https://xxxx/bootstrap.sh


实际输入的内容会破坏实例设置

# include

https://xxxx/bootstrap.sh

因此没有创建实例端的公钥

同样的事情也发生在我身上,但所发生的只是私钥从我本地机器上的钥匙链上丢失了。

ssh-add - k

重新添加密钥,然后SSH命令连接恢复工作。