Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having difficulty logging onto my Amazon ec2 instance. I set it up, downloaded the key. At first it complained because my permissions were setup correctly. Then I executed: chmod 400 myKey.pem. When I try to log in, I still get: Permission denied (publickey)

Next I deleted all of my keys and tried fresh: rm -rf ~/.ssh

I am confused by the other responses to this question. It seems like 1000 things could go wrong, and I'm not sure where to begin. I ran it with the -v option and it generated the following output (see below). Which I don't know exactly what to make of it.

As a beginner working through this, what should I try next?

-------------command output---------------

$ ssh -v -i myKey.pem 
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Connecting to
[] port 22.
debug1: Connection established.
debug1: identity file myKey.pem type -1
debug1: identity file myKey.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1
debug1: match: OpenSSH_5.3p1 Debian-3ubuntu5 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 d2:5b:dc:9e:b2:b1:f0:b1:13:2c:25:7f:ed:e1:9e:49
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /home/me/.ssh/known_hosts:1
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_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: myKey.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).
share|improve this question

migrated from Oct 27 '11 at 0:46

This question came from our site for professional and enthusiast programmers.

Ok I figured this one out by trial and error.

Below is the string that AMAZON told me to use.

ssh -v -i myKey.pem

Next is what I tried first

ssh -v -i myKey.pem

Error message says use bitnami.

ssh -v -i myKey.pem

Other than stumbling on this How was I supposed to know the user name was bitnami?

share|improve this answer
Where did you find the AMI that you decided to run? Never just pick an AMI out of a list of public AMIs presented to you by the console as any of them could have malicious code. Always go to a source you trust for a list of AMIs. When you do this, the source should also give you basics on how to connect to those AMIs. – Eric Hammond Oct 26 '11 at 23:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.