title: AWS EC2 SSH: Permission denied (publickey)
body: <p>I've configured my EC2 instance, and connected with SSH. But when I created a new Security Group with port rules I couldn't access via SSH anymore. Currently, my custom Security Group rules are:</p>
  
  <pre><code>SSH   0.0.0.0/0
  HTTP  0.0.0.0/0
  HTTPS 0.0.0.0/0
  </code></pre>
  
  <p>When I try <code>ssh -v -i bodruk.pem ubuntu@ec2-54-149-134-92.us-west-2.compute.amazonaws.com</code> I have the following error:</p>
  
  <pre><code>OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
  debug1: Connecting to ec2-54-149-134-92.us-west-2.compute.amazonaws.com [54.149.
  134.92] port 22.
  debug1: Connection established.
  debug1: identity file bodruk.pem type -1
  debug1: identity file bodruk.pem-cert type -1
  debug1: Enabling compatibility mode for protocol 2.0
  debug1: Local version string SSH-2.0-OpenSSH_6.6.1
  debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubu
  ntu-2ubuntu2
  debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000
  000
  debug1: SSH2_MSG_KEXINIT sent
  debug1: SSH2_MSG_KEXINIT received
  debug1: kex: server-&gt;client aes128-ctr hmac-md5-etm@openssh.com none
  debug1: kex: client-&gt;server aes128-ctr hmac-md5-etm@openssh.com none
  debug1: sending SSH2_MSG_KEX_ECDH_INIT
  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
  debug1: Server host key: ECDSA e2:13:af:e1:1b:70:f9:70:3b:cd:1d:7f:14:de:ce:90
  debug1: Host 'ec2-54-149-134-92.us-west-2.compute.amazonaws.com' is known and ma
  tches the ECDSA host key.
  debug1: Found key in /c/Users/Thiago/.ssh/known_hosts:2
  debug1: ssh_ecdsa_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: bodruk.pem
  debug1: key_parse_private2: missing begin marker
  debug1: read PEM private key done: type RSA
  debug1: Authentications that can continue: publickey
  debug1: No more authentication methods to try.
  Permission denied (publickey).
  </code></pre>
  
  <p>Already tried <a href="https://serverfault.com/questions/237953/amazon-ec2-ssh-failed-to-connect-bad-file-number">this solution</a>, but doesn't work. I changed the Key Pair twice and deleted the <em>known_hosts</em> file with no success.</p>
  
  <p>Any idea?</p>