UPDATE2:
$ ls -ld ~/.ssh drwx------ 8 user staff 272 2 Oct 17:51 /Users/user/.ssh $ ls -la ~/.ssh/config/file.pem -r--------@ 1 user staff 1692 2 Oct 17:11 /Users/user/.ssh/config/file.pem $ ls -la file.pem -rw-------@ 1 user staff 1692 2 Oct 17:11 localfile.pem
更新:
切换-i和-v标志后,我现在得到:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /Users/user/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 53: Applying options for * debug1: Connecting to ec2-XX-XX-XXX-XXX.areacode.compute.amazonaws.com [IP] port 22. debug1: Connection established. debug1: identity file file.pem type -1 debug1: identity file file.pem-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2 debug1: match: OpenSSH_6.2 pat OpenSSH* debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr [email protected] none debug1: kex: client->server aes128-ctr [email protected] 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: Server host key: RSA fingerprint debug1: Host 'ec2-XX-XX-XXX-XXX.ap-areacode.compute.amazonaws.com' is known and matches the RSA host key. debug1: Found key in /Users/user/.ssh/known_hosts:11 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: file.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).
我试图从我的MacterminalSSH入亚马逊Linux EC2实例。 我按照这些说明: http : //docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html
但是我得到的Permission denied (publickey)
我的安全设置允许我的公共IP地址为ssh。
它最初成功地:
Permanently added 'ec2-XX-XX-XXX-XXX.areacode.compute.amazonaws.com,YY.YY.YYY.YYY' (RSA) to the list of known hosts. $ ssh -i ec2vb.pem [email protected] Permission denied (publickey). $ ssh -i -v /path/to/ec2/file.pem [email protected] Warning: Identity file -v not accessible: No such file or directory. ssh: Could not resolve hostname /Developer/folder/ec2/file.pem: nodename nor servname provided, or not known
我也尝试更新权限chmod key 600和复制我的密钥到用户.ssh/config文件夹?
debug1: Trying private key: file.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).
您的客户端将密钥发送到服务器,服务器不接受它。 至于你的客户关心,你的私钥和本地文件和目录权限都很好。 你需要从服务器端解决这个问题。 我不知道如何EC2服务器是特殊的,但如果这是一个普通的Unix服务器,你会检查以下内容:
OpenSSH特别针对如何存储和使用密钥。 请执行下列操作:
1)创build并确保您的〜/ .ssh目录具有正确的权限:
$ mkdir ~/.ssh $ chmod 700 ~/.ssh $ ls -ld ~/.ssh drwx------ 2 username group 4096 Jun 10 19:47 /Users/username/.ssh
2)将私钥(在你的情况下.pem文件)复制到〜/ .ssh目录并设置适当的权限:
$ cp ~/Downloads/filename.pem ~/.ssh/filename.pem $ chmod 600 ~/.ssh/filename.pem
3)由于您使用OS X,请确保Finder没有设置任何不必要的扩展属性并将其删除:
$ xattr -l ~/.ssh/filename.pem $ xattr -d <attr_name> ~/.ssh/filename.pem
4)现在你可以尝试使用密钥:
$ ssh -i ~/.ssh/filename.pem [email protected]
5)一旦你validation了这个工作,你可以使用〜/ .ssh / config文件来更容易地连接到远程主机,而不必手动指定要使用的标识文件。 例如:
Host remote.hostname.com User username IdentityFile ~/.ssh/filename.pem
从这里开始,你可以运行ssh remote.hostname.com来连接你的远程服务器。