2015-11-09 3 views
1

Когда я пытаюсь выполнить ssh для моего экземпляра AWS, я получаю «Permission denied (publickey)».AWS ssh error 'Permission denied (publickey)'

Поиск этой проблемы обычно заключается в том, чтобы убедиться, что ключ .pem имеет правильные разрешения с 'chmod 600'. Другое решение входит в систему как пользователь root или ec2. Я пробовал и то, и другое.

Уникальным является то, что я могу использовать один и тот же ключ и входить в старый экземпляр AWS, а затем попытаться зарегистрировать мой новый созданный и получить отказ в разрешении. В AWS обе показывают, что используют одно и то же «имя пары ключей». Так что, если они имеют пару ключей одинаково в AWS, и ключ работает на одной коробке, почему проблема на другом поле?

коробка, которая выходит из строя (тот же ключ)

$ ssh -v -i .ssh/aws_match.pem [email protected] 
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 
debug1: Reading configuration data /etc/ssh_config 
debug1: /etc/ssh_config line 20: Applying options for * 
debug1: Connecting to 52.23.xxx.xxx [52.23.xxx.xxx] port 22. 
debug1: Connection established. 
debug1: identity file .ssh/aws_match.pem type -1 
debug1: identity file .ssh/aws_match.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.6.1 
debug1: match: OpenSSH_6.6.1 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 5c:5b:54:a6:50:ec:3b:ba:aa:4f:00:2a:90:b3:a9:9b 
debug1: Host '52.23.195.151' is known and matches the RSA host key. 
debug1: Found key in /Users/pumphreyjj/.ssh/known_hosts:12 
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: .ssh/aws_match.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). 

Ящик, который работает (тот же ключ)

$ ssh -v -i .ssh/aws_match.pem [email protected] 
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 
debug1: Reading configuration data /etc/ssh_config 
debug1: /etc/ssh_config line 20: Applying options for * 
debug1: Connecting to 54.84.xx.xxx [54.84.xx.xxx] port 22. 
debug1: Connection established. 
debug1: identity file .ssh/aws_match.pem type -1 
debug1: identity file .ssh/aws_match.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_5.3 
debug1: match: OpenSSH_5.3 pat OpenSSH_5* 
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 f0:94:93:93:fa:1d:37:ec:6d:0a:22:78:2e:9c:d1:13 
debug1: Host '54.84.81.152' is known and matches the RSA host key. 
debug1: Found key in /Users/pumphreyjj/.ssh/known_hosts:3 
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,gssapi-keyex,gssapi-with-mic,password 
debug1: Next authentication method: publickey 
debug1: Trying private key: .ssh/aws_match.pem 
debug1: read PEM private key done: type RSA 
debug1: Authentication succeeded (publickey). 
Authenticated to 54.84.xx.xxx ([54.84.xx.xxx]:22). 
debug1: channel 0: new [client-session] 
debug1: Requesting [email protected] 
debug1: Entering interactive session. 
debug1: Sending environment. 
debug1: Sending env LANG = en_US.UTF-8 
Last login: Mon Nov 9 10:43:36 2015 from 128.231.xxx.xxx 

Единственное различие, которое я вижу, это версия OpenSSH, но устанавливается по AWS. Я еще не изменил окно.

+0

Невозможно расследовать это из этого журнала. Вы должны проверить журнал на стороне сервера, где вы найдете более подробную информацию. На обеих машинах будет, вероятно, другая конфигурация. – Jakuje

+0

Какой AMI вы используете? Amazon Linux, Ubuntu, ...? – Andreas

+0

Это Amazon Linux – JPump

ответ

0

Оказывается, что старая коробка была построена с определенным изображением и этот локальный ключ был загружен в AWS. По какой-то причине новые окна не работали с этим ключом. Я работал над этим, создав новый ключ для новых ящиков, и теперь он работает нормально.

Смежные вопросы