I have set up ssh key pairs between my desktop and two servers, and from the servers to my desktop, but after reinstalling the OS on my desktop, I can't re-establish the keypair going into my desktop by this:
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t
ssh-copy-id username@server
I get the following error:
(names in italics changed to protect the innocent My desktop is Ubuntu, and I can't find the answer here)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is ab:cd:ef:gh Please contact your system administrator. Add correct host key in /home/user/.ssh/known_hosts to get rid of this message. Offending key in /home/user/.ssh/known_hosts:1 RSA host key for user.server has changed and you have requested strict checking. Host key verification failed.
Step1:$Bhargava.ssh#
step2:$Bhargava.ssh #
step3: Bhargava .ssh #
hostname@qt:~$
First you should remove existing key. SSH keys in most of Linux-based OS will be saved this file "/root/.ssh/known_hosts", so in order to remove the key related to host the following command will be used:
ssh-keygen -f "/root/.ssh/known_hosts" -R [Hostname]
Regards K1
This deletes the offending key from the
known_hosts
The man page entry reads:
This issue arises when the host key is expired or changed. you can remove the keys that host is using and try to ssh again, so that you are adding new key that is known to both client and server.
You can check the keys associated with your hosts with
cat /.ssh/known_hosts
. Now, You can remove the hosts keys manually or using the ssh-keygen option. You can do either of the following option.Manual removal of keys
vim /.ssh/known_hosts
delete the key that is associated with your host.
Remove key using ssh-keygen
ssh-keygen -R your_host_or_host_ip
This will remove your key associated with the host.
Now, you can ssh to your host as usual and you will be asked if you want to continue to this host. Once your enter yes, this host will be added to your/.ssh/known_hosts with updated key. By now, you should be your host.
Task Passwordless authentication for suer.
Error : Host key verification failed.
Source :10.13.1.11 Target : 10.13.1.35
Temporary workaround :
[user@server~]$ ssh user@10.13.1.35 The authenticity of host '10.13.1.35 (10.13.1.35)' can't be established. RSA key fingerprint is b8:ba:30:46:a9:ab:70:12:1a:f2:f1:61:69:73:0a:19. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.13.1.35' (RSA) to the list of known hosts.
Try to authenticate user again...it will work.
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 exists, while it does.In above case just remove /dev/tty and create a symlink of /dev/ttyS0 to /dev/tty.