我无法ssh到我的EC2服务器并收到错误:
ssh -i /Users/Skeniver/Keepass/skeniver.pem [email protected]
Identity file /Users/Skeniver/Keepass/skeniver.pem not accessible: No such file or directory
该文件肯定在目录中,我已将目录chmod为755,文件为600:
drwxr-xr-x 14 Skeniver staff 476 28 Nov 2012 Keepass
-rw------- 1 Skeniver staff 1696 5 Oct 2012 skeniverkey.pem
我很确定这是一个权限问题,但无法弄清楚为什么......
以下是使用-v的ssh命令的输出,如果有任何用处:
Warning: Identity file /Users/Skeniver/Keepass/skeniver.pem not accessible: No such file or directory.
OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to xx.xxx.xx.xxx [xx.xxx.xx.xxx] port 22.
debug1: Connection established.
debug1: identity file /Users/Skeniver/.ssh/identity type -1
debug1: identity file /Users/Skeniver/.ssh/id_rsa type 1
debug1: identity file /Users/Skeniver/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'xx.xxx.xx.xxx' is known and matches the RSA host key.
debug1: Found key in /Users/Skeniver/.ssh/known_hosts:8
debug1: ssh_rsa_verify: signature correct
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 public key: /Users/Skeniver/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/Skeniver/.ssh/identity
debug1: Trying private key: /Users/Skeniver/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
您需要身份文件才能登录该框。使用命令:
ssh -i (identity_file) username@hostname"
这对我有用。只写文件名(没有任何斜杠),不像Amazon EC2教程要求你输入:
ssh -i /path/key_pair.pem ec2-user@public_dns_name
将身份文件放在主页上的.ssh(隐藏)文件夹后,它对我有用。要在家中查看隐藏文件夹,请使用ctrl+h
我有类似的问题,发现命令中有隐藏的字符,粘贴到纯文本编辑器并复制回来帮助了我。
我遇到了同样的问题。将标识文件存储在我的~/.ssh
目录中并在cd ~/.ssh
工作之前运行ssh -i (identity_file) username@hostname
。尝试从~/.ssh
目录外部运行ssh命令时,我只遇到了这个问题。希望这会有所帮助
对于你的情况只是
只需执行以下命令即可更改权限
sudo chmod 400 /Users/Skeniver/Keepass/skeniver.pem
然后执行将您连接到EC2的命令
ssh -i /Users/Skeniver/Keepass/skeniver.pem [email protected]
我有同样的问题,我发现文件路径的问题。右键单击你的key_pair.pem(相同的文件)去属性并复制,现在你的评论就像
ssh -i /path/skeniver.pem user@your_public_ip
例如在我的情况下命令就像
ssh -i /home/anil/.ssh/webKey.pem [email protected]
您需要身份文件才能登录该框。使用该命令
ssh -i (identity_file) username@hostname
尝试使用
ssh -i Users/Skeniver/Keepass/skeniver.pem [email protected]
代替
ssh -i **/**Users/Skeniver/Keepass/skeniver.pem [email protected]
chmod 600 ~/.ssh/public_key_file
为我解决了