title: Amazon ssh permission denied (public key) with error message
body: <p>I just set up my AWS Deep Learning instance and paired it to a new key pairs file I created.</p>
  
  <p>However, when I try to ssh with the following command:</p>
  
  <pre><code>ssh -v -i /Users/username/aws-deep-learning-ami.pem ubuntu@INSTANCE_IP.compute.amazonaws.com
  </code></pre>
  
  <p>I get the rather long error message: permission denied (public key).</p>
  
  <p>Printing the details with -v shows this:</p>
  
  <pre><code>OpenSSH_7.2p2, OpenSSL 1.0.2k  26 Jan 2017
  debug1: Reading configuration data /etc/ssh_config
  debug1: /etc/ssh_config line 57: Applying options for *.com
  debug1: /etc/ssh_config line 67: Applying options for *.*
  debug1: /etc/ssh_config line 77: Applying options for *
  debug1: Connecting to instance.amazonaws.com [ip] port 22.
  debug1: using TCP window size of 65536 / 65536
  debug1: Connection established.
  debug1: key_load_private_cert: No such file or directory
  debug1: key_load_cert: No such file or directory
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/aws-deep-learning-ami.pem type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/aws-deep-learning-ami.pem-cert type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/id_rsa type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/id_rsa-cert type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/localhost/id_rsa type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/localhost/id_rsa-cert type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/clusterhost/id_rsa type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file /Users/username/.ssh/clusterhost/id_rsa-cert type -1
  debug1: Enabling compatibility mode for protocol 2.0
  debug1: Local version string SSH-2.0-OpenSSH_7.2
  debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
  debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
  debug1: Authenticating to instance as 'ubuntu'
  debug1:  Miscellaneous failure (see text)
  No credentials cache file found
  
  debug1: SSH2_MSG_KEXINIT sent
  debug1: SSH2_MSG_KEXINIT received
  debug1: kex: algorithm: key
  debug1: kex: host key algorithm: key
  debug1: kex: server-&gt;client cipher: key MAC: &lt;implicit&gt; compression: none
  debug1: kex: client-&gt;server cipher: key MAC: &lt;implicit&gt; compression: none
  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
  debug1: Server host key: key
  debug1: Host 'instance.compute.amazonaws.com' is known and matches the ECDSA host key.
  debug1: Found key in /Users/username/.ssh/known_hosts:7
  debug1: SSH2_MSG_NEWKEYS sent
  debug1: expecting SSH2_MSG_NEWKEYS
  debug1: SSH2_MSG_NEWKEYS received
  debug1: SSH2_MSG_SERVICE_ACCEPT received
  debug1: Authentications that can continue: publickey
  debug1: Next authentication method: publickey
  debug1: Offering ECDSA public key: publickey
  debug1: Authentications that can continue: publickey
  debug1: Offering ECDSA-CERT public key: corp/normal
  debug1: Authentications that can continue: publickey
  debug1: Trying private key: /Users/username/aws-deep-learning-ami.pem
  debug1: Authentications that can continue: publickey
  debug1: Trying private key: /Users/username/.ssh/id_rsa
  debug1: Trying private key: /Users/username/.ssh/localhost/id_rsa
  debug1: Trying private key: /Users/username/.ssh/clusterhost/id_rsa
  debug1: No more authentication methods to try.
  Permission denied (publickey).
  </code></pre>