I can connect to another Ubuntu machine in my LAN via SSH. On both of then PC's I installed openssh-server but from another Ubuntu computer I can not connect to my PC via SSH and I got this error:
Host key verification failed...
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
"Host key verification failed" means that the host key of the remote host was changed.
SSH stores the host keys of the remote hosts in
~/.ssh/known_hosts. You can either edit that text file manually and remove the old key (you can see the line number in the error message), or use
ssh-keygen -R hostname
From man page:
Removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts .
(which I learned from the answer to Is it possible to remove a particular host key from SSH's known_hosts file?).
If you are running in certain remote/scripting situations where you lack interactive access to the prompt-to-add-hostkey, work around it like this:
$ ssh -o StrictHostKeyChecking=no email@example.com uptime
Warning: Permanently added 'something.example.com,10.11.12.13' (RSA) to the list of known hosts.
Also sometimes there is situation when you are working on serial console, then checking above command in verbose mode
-v will show you
/dev/tty does not exist, while it does.
ssh -v user@hostname
In above case just remove
/dev/tty and create a symlink of
rm /dev/tty ln -s /dev/ttyS0 /dev/tty
As an alternative, add
id_rsa.pub to the remote location, so password is not prompted and you get login access.
ssh -o StrictHostKeyChecking=no -i YourPublicKey.pem firstname.lastname@example.org uptime
The following message, or similar, will appear:
Warning: Permanently added 'example.com, XX.XXX.XXX.XX' (ECDSA) to the list of known hosts. 00:47:37 up 3 min, 0 users, load average: 0.00, 0.00, 0.00
Then, connect to your EC2 as normal:
ssh -i YourPublickey.pem email@example.com
May be you just need to enter "yes" when ssh confirm you want to continue connectting.
The authenticity of host 'xxx' can't be established. ECDSA key fingerprint is yyy. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'xxx' (ECDSA) to the list of known hosts. Enter passphrase for key '/Users/ysy/.ssh/id_rsa':
Then enter your password.
Please pay attention to "Are you sure you want to continue connecting (yes/no)? yes". You must enter yes, not enter.
Well, it simply because the second ubuntu requires connection by key and not password.
I suggest you use
sudo dpkg-reconfigure openssh-server on your pc, and then it should work properly. It will reset the configuration for openssh and should come back to a default password authentication.
Second possibility is that there's already a key for your other ubuntu in you PC, and that it changed thus being not recognized anymore. In this case, you'll have to edit the file
.ssh/authorized_keys to remove the problematic line identifying your ubuntu.
This is an old thread and I just ran across this answer, I will just add what I did to solve this.
ssh-keygen -f "/home/USER/.ssh/known_hosts" -R HOSTNAME
I just looked at the error message that it threw at me and it said to run that command in order to remove it from the list of hosts. After that I did the following:
Than I followed the prompts from there until I was able to ssh into the server.
Its means your remote host key was changed (May be host password change),
Your terminal suggested to execute this command as root user
$ ssh-keygen -f "/root/.ssh/known_hosts" -R [www.website.net]:4231
You have to remove that host name from hosts list on your pc/server. Copy that suggested command and execute as a root user.
$ sudo su // Login as a root user $ ssh-keygen -f "/root/.ssh/known_hosts" -R [www.website.net]:4231 // Terminal suggested command execute here Host [www.website.net]:4231 found: line 16 type ECDSA /root/.ssh/known_hosts updated. Original contents retained as /root/.ssh/known_hosts.old $ exit // Exist from root user $ sudo ssh firstname.lastname@example.org -p 4231 // Try again
Hope this works.
Just do "sudo vi /var/root/.ssh/known_hosts" and remove the line, that holds a key for a host you're trying to connect to and reconnect again.
I don't know about your particular situation, but most probably this error came along with a message like this:
my_mac:~ oivanche$ sudo ssh email@example.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:sx1Z4xyGY9venBP6dIHAoBj0VhDOo7TUVCE2xWXpzQk. Please contact your system administrator. Add correct host key in /var/root/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /var/root/.ssh/known_hosts:74 ECDSA host key for 192.168.0.45 has changed and you have requested strict checking. Host key verification failed.
If you'll read the log more carefully you'll see that the key you've got from a host is conflicting with a key you already have - in this case it's on line 74 of known_hosts file (Offending ECDSA key in /var/root/.ssh/known_hosts:74). Remove the line from the known_hosts, save changes and reconnect.
My solution comes from this blog post: Algorithm negotiation failed for SSH Secure Shell Client
You need to modify the file as follows:
sudo nano /etc/ssh/sshd_config
And then add the following:
# Ciphers Ciphers aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,arcfour KexAlgorithms diffie-hellman-group1-sha1
Basically you tried different solutions until you find one which can solve your problem. If the above solutions don't work, please try this one. If this one doesn't work as well, please try others.