0

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?

harryg
  • 23,311
  • 45
  • 125
  • 198
  • What are the log lines in your `/var/log/auth.log` when the login attempts failed? – clement Mar 27 '14 at 11:48
  • Have you changed the username and groupname of the keyfile to the current acces user of the client machine ? Also change the keyfile permission to 400 and try again – Sathish Mar 27 '14 at 11:48
  • Given I am not on a UNIX machine do I have a `var/log` directory? – harryg Mar 27 '14 at 11:56
  • @Sathish no I haven't change the username/groupname. I simply downloaded it from my dropbox and tried to use it. `chmod 400` doesn't seem to help. – harryg Mar 27 '14 at 11:57
  • Please change the username and groupname to your current username of the machine and try again – Sathish Mar 27 '14 at 12:03
  • Actually, checking the file's properties it seem the owner is the current user on the machine – harryg Mar 27 '14 at 12:11

1 Answers1

0

.\key_pair.pem is wrong.

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

slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123