mardi 22 avril 2014

les services web Amazon - impossible de se connecter à AWS EC2 à l'aide de la clé privée envoyé à moi-même (Permission denied : clé publique)-Stack Overflow


I know this is an issue that is common but I believe the cause in my case is not the usual.


I have an ubuntu AWS EC2 instance that I access using the private key on my mac.


I wanted access whilst I'm at work so I put the key in my dropbox account and downloaded it onto my work (windows) pc and placed in the C:/Users/[myusername]/.ssh directory. I also chmod 600'd it.


I'm using the Git shell for ssh as it has SSH and I don't want to install putty for now.


So I run the command


C:\Users\[myusername]\.ssh> ssh -v -i .\key_pair.pem ubuntu@[redacted].compute.amazonaws.com

(with the correct dns name of course.)


Here is the output:


OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to [redacted].compute.amazonaws.com [[redacted]] port 22.
debug1: Connection established.
debug1: identity file .\\key_pair.pem 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_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc 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
Warning: Permanently added '[redacted].compute.amazonaws.com,[redacted]' (RSA) to the list of known hosts.
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: C:\\Users\\[myusername]\\.ssh\\github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: .\\key_pair.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).

I'm sure that the key I used is correct as it works on my Mac. Is there anything else I'm doing wrong?


Edit: I notice the debug output mentions:


debug1: Offering public key: C:\\Users\\[myusername]\\.ssh\\github_rsa

Does the fact that it's offering an unrelated public key affect authentication?




.\key_pair.pem is wrong.


Use ./key_pair.pem instead with Git bash (it doesn't matter whether you are on windows)



I know this is an issue that is common but I believe the cause in my case is not the usual.


I have an ubuntu AWS EC2 instance that I access using the private key on my mac.


I wanted access whilst I'm at work so I put the key in my dropbox account and downloaded it onto my work (windows) pc and placed in the C:/Users/[myusername]/.ssh directory. I also chmod 600'd it.


I'm using the Git shell for ssh as it has SSH and I don't want to install putty for now.


So I run the command


C:\Users\[myusername]\.ssh> ssh -v -i .\key_pair.pem ubuntu@[redacted].compute.amazonaws.com

(with the correct dns name of course.)


Here is the output:


OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to [redacted].compute.amazonaws.com [[redacted]] port 22.
debug1: Connection established.
debug1: identity file .\\key_pair.pem 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_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc 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
Warning: Permanently added '[redacted].compute.amazonaws.com,[redacted]' (RSA) to the list of known hosts.
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: C:\\Users\\[myusername]\\.ssh\\github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: .\\key_pair.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).

I'm sure that the key I used is correct as it works on my Mac. Is there anything else I'm doing wrong?


Edit: I notice the debug output mentions:


debug1: Offering public key: C:\\Users\\[myusername]\\.ssh\\github_rsa

Does the fact that it's offering an unrelated public key affect authentication?



.\key_pair.pem is wrong.


Use ./key_pair.pem instead with Git bash (it doesn't matter whether you are on windows)


0 commentaires:

Enregistrer un commentaire