Ubuntu – SSH “Host key verification failed”

serverssh

I am supposed to put up a file on a server from my own computer with ssh as a school assignment.

It has been a slow process but now I'm stuck. I have googled but not found anything that has helped. As I am a total beginner at this it is probably some stupid fault of mine, so please help me out (easy instructions, expect me to do it wrong 😉 ) . Below is the terminal text from where I am stuck, I have tried both logged in on my computer and logged in on the server.

logged in on the server:

teddy@rymd-srv:~$ ssh-keygen -R teddy@elev.rymdgymnasiet.com
/home/teddy/.ssh/known_hosts updated.
Original contents retained as /home/teddy/.ssh/known_hosts.old
teddy@rymd-srv:~$ scp -r teddy@85.226.40.57:/home/teddy/Pictures/filetransfer.jpeg 
teddy@elev.rymdgymnasiet.com:/home/teddy
teddy@85.226.40.57's password:
Host key verification failed.
lost connection

logged in on my own computer:

teddy@TeddysDator:~$ ssh-keygen -R teddy@elev.rymdgymnasiet.com 
/home/teddy/.ssh/known_hosts updated.
Original contents retained as /home/teddy/.ssh/known_hosts.old
teddy@TeddysDator:~$ scp -r teddy@85.226.40.57:/home/teddy/Pictures/filetransfer.jpeg 
teddy@elev.rymdgymnasiet.com:/home/teddy
The authenticity of host '85.226.40.57 (85.226.40.57)' can't be established.
ECDSA key fingerprint is ef:9c:4c:41:3c:9d:b1:40:05:67:30:34:e8:d3:ab:c6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '85.226.40.57' (ECDSA) to the list of known hosts.
teddy@85.226.40.57's password:
Host key verification failed.
lost connection

Best Answer

This is likely a problem with how older versions of SSH handle host verification when ECDSA is used by default.

If you trust that the server and network have not been compromised, just add the host's RSA key to your known_hosts file:

ssh-keyscan ssh-server.example.com | tee -a ~/.ssh/known_hosts