亚马逊ssh权限被拒绝(公钥),并显示错误消息

时间:2017-06-24 22:50:47

标签: amazon-web-services amazon-ec2

我只是设置了我的AWS Deep Learning实例,并将其与我创建的新密钥对文件配对。

但是,当我尝试使用以下命令ssh时:

ssh -v -i /Users/username/aws-deep-learning-ami.pem ubuntu@INSTANCE_IP.compute.amazonaws.com

我收到相当长的错误消息:权限被拒绝(公钥)。

使用-v打印详细信息显示:

OpenSSH_7.2p2, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 57: Applying options for *.com
debug1: /etc/ssh_config line 67: Applying options for *.*
debug1: /etc/ssh_config line 77: Applying options for *
debug1: Connecting to instance.amazonaws.com [ip] port 22.
debug1: using TCP window size of 65536 / 65536
debug1: Connection established.
debug1: key_load_private_cert: No such file or directory
debug1: key_load_cert: No such file or directory
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/aws-deep-learning-ami.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/aws-deep-learning-ami.pem-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/localhost/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/localhost/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/clusterhost/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/clusterhost/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to instance as 'ubuntu'
debug1:  Miscellaneous failure (see text)
No credentials cache file found

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: key
debug1: kex: host key algorithm: key
debug1: kex: server->client cipher: key MAC: <implicit> compression: none
debug1: kex: client->server cipher: key MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: key
debug1: Host 'instance.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/username/.ssh/known_hosts:7
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering ECDSA public key: publickey
debug1: Authentications that can continue: publickey
debug1: Offering ECDSA-CERT public key: corp/normal
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/username/aws-deep-learning-ami.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/username/.ssh/id_rsa
debug1: Trying private key: /Users/username/.ssh/localhost/id_rsa
debug1: Trying private key: /Users/username/.ssh/clusterhost/id_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).

2 个答案:

答案 0 :(得分:1)

通常,默认用户名为:

  • Amazon Linux使用ec2-user
  • Ubuntu AMI使用ubuntu
  • Amazon EMR使用hadoop

答案 1 :(得分:0)

正如stdunbar所提到的,我必须使用ec2-user而不是ubuntu