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


当前回答

这个问题可以通过下面的命令登录Ubuntu系统来解决:

ssh -i ec2key.pem ubuntu@ec2-public-IP

其他回答

这种情况在我身上发生过很多次。我使用的是Amazon Linux AMI 2013.09.2和Ubuntu Server 12.04.3 LTS,它们都在免费层。

每次我启动一个实例,我都有拒绝显示的权限。我还没有验证这一点,但我的理论是,在我尝试ssh进入它之前,服务器还没有完全设置好。在尝试了几次被拒绝后,我等了几分钟,然后我就可以连接了。如果你遇到这个问题,我建议你等五分钟再试一次。

这就是我解决问题的方法

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

我也犯过类似的错误

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

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

这是一个基本的事情,但一定要确认您要登录哪个用户。我的案子只是分散你的注意力。我试着用root用户

ssh -i ~/keys/<key_name> root@111.111.111.111

但另一位用户说:

ssh -i ~/keys/<key_name> dedeco@111.111.111.111

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

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".