权限被拒绝(publickey)通过SSH连接Amazon EC2

当我试图通过SSH连接。 没关系,但经过我的一些操作: – [我已经下载密钥对,复制到.ec2,chmod到600,ssh-keygen -y -f〜/ .ec2 / gsg-keypair>〜/ .ec2 / gsg -keypair.pub我正在使用MacOS。 我认为这是权限的问题…但我已经尝试了所有组合和所有build议)

.ec2/ ls -l -rw-------@ 1 olegpasko staff 1692 Apr 2 02:26 gsg-keypair -rw-r--r-- 1 olegpasko staff 381 Apr 2 10:55 gsg-keypair.pub .ssh/ ls -l -rw------- 1 olegpasko staff 1766 Jun 8 2012 github_rsa -rw-r--r-- 1 olegpasko staff 398 Jun 8 2012 github_rsa.pub -rw------- 1 olegpasko staff 398 May 25 2012 github_rsa.pub_bak-github -rw------- 1 olegpasko staff 1766 May 25 2012 github_rsa_bak-github -rw------- 1 olegpasko staff 1766 Jun 28 2012 id_rsa -rw-r--r-- 1 olegpasko staff 401 Jun 28 2012 id_rsa.pub drw------- 2 olegpasko staff 68 Jun 28 2012 key_backup -rw-------@ 1 olegpasko staff 5218 Apr 2 02:29 known_hosts -rw-------@ 1 olegpasko staff 5218 Mar 31 13:55 known_hosts.bak 

尝试连接:

 ssh -i gsg-keypair [email protected] -v OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011 debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: Connecting to ec2-54-247-7-28.eu-west-1.compute.amazonaws.com http://54.247.7.28 port 22. debug1: Connection established. debug1: identity file gsg-keypair type 1 debug1: identity file gsg-keypair-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1 debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.9 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: Server host key: RSA 43:81:01:0d:a6:ff:9d:85:48:18:97:7a:12:4a:16:27 debug1: Host 'ec2-54-247-7-28.eu-west-1.compute.amazonaws.com' is known and matches the RSA host key. debug1: Found key in /Users/olegpasko/.ssh/known_hosts:13 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: Offering RSA public key: /Users/olegpasko/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Offering RSA public key: gsg-keypair debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). 

🙁

你需要修复你的sshdconfiguration。 您可以按照http://aws.amazon.com/instance-help/#no-response中的“EBS-Backed Instances :: Instance Recovery”部分执行此操作。

第4步:“更正旧的根卷上的configuration”。 是你需要去操纵你的sshd_config的地方。

由于实例和卷的操作是痛苦的缓慢,你应该testing你的去sird_config工作,通过使用configuration在不同的端口上启动sshd。 确保实例的安全组允许连接到该端口。

假设您正在使用Amazon Linux AMI,则会禁用rootlogin。 试试ssh -i gsg-keypair [email protected] -v