我正在尝试连接到AWS实例。我知道我肯定已经在桌面上下载了密钥对,但由于某些原因它无法识别它?我已使用chmod 400
更改了权限,但仍会发生以下情况:
martycep:~ martincepeda1$ ssh -v -i “privatekey.pem” ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com
Warning: Identity file privatekey.pem not accessible: No such file or directory.
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to ec2-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com [xx.xx.xxx.xx] port 22.
debug1: Connection established.
debug1: identity file /Users/martincepeda1/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/martincepeda1/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
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 ec2-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key:xxxxxxxxxxxxxx
debug1: Host 'ec2-xx-xx-xxx-xx.us-east-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/martincepeda1/.ssh/known_hosts:6
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/martincepeda1/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/martincepeda1/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/martincepeda1/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/martincepeda1/.ssh/id_dsa
debug1: Trying private key: /Users/martincepeda1/.ssh/id_ecdsa
debug1: Trying private key: /Users/martincepeda1/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
martycep:~ martincepeda1$
任何建议/想法将不胜感激。谢谢。
答案 0 :(得分:0)
你能检查一下:
您使用的是正确的密钥位置。
密钥具有正确的权限。
您使用的是正确的密钥吗?
答案 1 :(得分:0)
警告:无法访问身份文件privatekey.pem:没有此类文件或 目录强>
此输出表明您没有任何名为“privatekey.pem”的文件
也许你改变了关键权限,如:
chmod 0400 **~/.ssh/privatekey.pem**
该文件应如下所示:
-r--------+ 1 user group 1671 Jun 5 11:37 privatekey.pem
在那种情况下你应该这样做:
ssh -i **~/.ssh/privatekey.pem** ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com
检查你的钥匙在哪里!
解决之后,不要忘记你必须在主机中添加公钥:ec2-user@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com
cat 'your_public_key' >> ~/.ssh/authorized_keys
否则您的私钥将与服务器中的公钥不匹配。