2017-06-24 140 views
-2

我剛剛設置了我的AWS Deep Learning實例,並將其與我創建的新密鑰對文件配對。Amazon ssh權限被拒絕(公鑰),出現錯誤消息

然而,當我嘗試用下面的命令SSH:

ssh -v -i /Users/username/aws-deep-learning-ami.pem [email protected]_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). 
+0

這只是意味着憑據不起作用 - 錯誤的憑據,錯誤的用戶,不管。這不是一個真正的編程問題,或許更好[su]或[sf] – pvg

+0

感謝您的快速回復!我應該爲每個密鑰對使用不同的用戶嗎? – user3642173

+0

請嘗試用戶ec2-user。 – stdunbar

回答

1

一般情況下,默認的用戶名是:

  • 亞馬遜Linux使用ec2-user
  • Ubuntu AMI使用ubuntu
  • Amazon EMR使用hadoop
0

正如stdunbar提到的,我不得不使用EC2用戶,而不是Ubuntu的