title: SSH connection to Amazon EC2 with private key fails
body: <p>I'm trying to connect to the problematic Amazon EC2 instance with this command:</p>
  
  <pre><code>ssh -vvv -i MY_KEY.pem root@ec2-XX-XX-XXX-XX.compute-1.amazonaws.com
  </code></pre>
  
  <p>and getting this result:</p>
  
  <pre><code>OpenSSH_7.5p1, OpenSSL 1.1.0g-fips  2 Nov 2017
  debug1: Reading configuration data /etc/ssh/ssh_config
  debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
  debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
  debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *
  debug1: Connecting to ec2-XX-XX-XXX-XX.compute-1.amazonaws.com [XX.XX.XXX.XX] port 22.
  debug1: Connection established.
  debug1: key_load_public: No such file or directory
  debug1: identity file MY_KEY.pem type -1
  debug1: key_load_public: No such file or directory
  debug1: identity file MY_KEY.pem-cert type -1
  debug1: Enabling compatibility mode for protocol 2.0
  debug1: Local version string SSH-2.0-OpenSSH_7.5
  debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
  debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
  debug1: Authenticating to ec2-XX-XX-XXX-XX.compute-1.amazonaws.com:22 as 'root'
  debug1: SSH2_MSG_KEXINIT sent
  debug1: SSH2_MSG_KEXINIT received
  debug1: kex: algorithm: curve25519-sha256@libssh.org
  debug1: kex: host key algorithm: ecdsa-sha2-nistp256
  debug1: kex: server-&gt;client cipher: aes256-gcm@openssh.com MAC: &lt;implicit&gt; compression: none
  debug1: kex: client-&gt;server cipher: aes256-gcm@openssh.com MAC: &lt;implicit&gt; compression: none
  debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32
  debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32
  debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
  debug1: Server host key: ecdsa-sha2-nistp256 SHA256:rRMQg/hs
  debug1: Host 'ec2-XX-XX-XXX-XX.compute-1.amazonaws.com' is known and matches the ECDSA host key.
  debug1: Found key in /home/dina/.ssh/known_hosts:8
  debug1: rekey after 4294967296 blocks
  debug1: SSH2_MSG_NEWKEYS sent
  debug1: expecting SSH2_MSG_NEWKEYS
  debug1: SSH2_MSG_NEWKEYS received
  debug1: rekey after 4294967296 blocks
  debug1: SSH2_MSG_EXT_INFO received
  debug1: kex_input_ext_info: server-sig-algs=&lt;ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521&gt;
  debug1: SSH2_MSG_SERVICE_ACCEPT received
  debug1: Authentications that can continue: publickey,password,keyboard-interactive
  debug1: Next authentication method: publickey
  debug1: Offering RSA public key: MY_KEY.pem
  debug1: Authentications that can continue: publickey,password,keyboard-interactive
  debug1: Offering RSA public key: dina@localhost.localdomain
  debug1: Authentications that can continue: publickey,password,keyboard-interactive
  debug1: Trying private key: MY_KEY.pem
  debug1: Authentications that can continue: publickey,password,keyboard-interactive
  debug1: Next authentication method: keyboard-interactive
  Password: 
  </code></pre>
  
  <p>The key MY_KEY.pem should be correct, I've checked the fingerprint under NETWORK &amp; SECURITY -> Key Pairs on AWS console, and it's the same as for the key I'm using. </p>
  
  <p>Permissions for the .pem file is 400, owner is current owner. SSH inbound traffic to the instance is allowed from all addresses.</p>
  
  <p>Also tried this with different users (root, ubuntu, admin, ec2-user,  centos, fedora) as I have no contact with the person who launched the instance and have no idea what system is there.</p>
  
  <p>Any idea about what is going on and what could be done about it? Your help is very much appreciated</p>