title: Permission denied (public key) during SSH to EC2 instance
body: <p>I am having problems with my key pairs and likely SSH permissions as I can no longer SSH into my EC2 instances. </p>
  
  <p>I execute the following command:</p>
  
  <pre><code>ssh -i /Users/Matt/Downloads/private-key.pem ec2-user@XX.XXX.XXX.XXX
  </code></pre>
  
  <p>Keep in mind I just created this key pair in the AWS Management Console which downloaded the key .pem file to my downloads file. I then get the following error message after replying "yes" to continue connecting.</p>
  
  <pre><code>Failed to add the host to the list of known hosts 
  (/Users/Matt/.ssh/known_hosts).
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  Permissions 0644 for '/Users/Matt/Downloads/private-key.pem' are too open.
  It is required that your private key files are NOT accessible by others.
  This private key will be ignored.
  Load key "/Matt/Downloads/private-key.pem": bad permissions
  Permission denied (publickey).
  </code></pre>
  
  <p>Ok so I've spent the better part of a day troubleshooting this and have tried retrieving the pub file, importing that as a key pair, etc. and still I get permission denied (public key) or am prompted for a non-existent instance associated password. I am fairly certain this must be an issue with my own SSH permissions but I am lost. </p>
  
  <p>This is what I get in the terminal after an ssh -v</p>
  
  <pre><code> usage: ssh [-XXXXXXXXXXXXXXX] [-b bind_address] [-c cipher_spec]
         [-D [bind_address:]port] [-E log_file] [-e escape_char]
         [-F configfile] [-I pkcs11] [-i identity_file]
         [-L [bind_address:]port:host:hostport] [-l login_name] [-m 
   mac_spec]
         [-O ctl_cmd] [-o option] [-p port]
         [-Q cipher | cipher-auth | mac | kex | key]
         [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
         [-w local_tun[:remote_tun]] [user@]hostname [command]
  </code></pre>
  
  <p>Any help would be sincerely appreciated.</p>