I recently created my first EC2 instance through Amazon Web Services and uploaded my SSH certificate found in my .ssh folder on my users mac home folder. Through the terminal I now try to connect to my instance using elastic IP and it works when I prepend the SSH call with sudo. When I omit sudo I get an error message
Add correct host key in /Users/ola/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/ola/.ssh/known_hosts:13
RSA host key for 54.247.165.223 has changed and you have requested strict checking.
Host key verification failed.
The same problem occurs as I try to log into the server using a SFTP connection.
My question, I guess, is why doesn’t it work when the key pair I use is the one uploaded from my users .ssh directory (and the same I use for some other services), and why it works when I add sudo.
Another question will then be, what is the difference between having the keys, both private and public, in .ssh under the user root or saving it in a known_host folder. Is there any different convention from unix on mac, linux and other system, or is this standard across every platform.
(I run an Ubuntu server as my AMI)
It seems your known_hosts file has an old or conflicting entry for that IP from a previous point in time. If you edit that file and remove line 13 (matching that ip) and save, when you connect again it should act like the first time and add it to known_hosts properly.
That file is where public keys are stored from previous connections to speed up future ones by simply using the key right away.