DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Remove key from known_hosts


If you use some virtual host with the same IP, you will always see messages below:

$ ssh ansible@console.newfairs-inc.com
Warning: the ECDSA host key for 'console.newfairs-inc.com' differs
from the key for the IP address '192.168.100.201'
Offending key for IP in /home/user/.ssh/known_hosts:48
Matching host key in /home/user/.ssh/known_hosts:39
Are you sure you want to continue connecting (yes/no)?

Or something like this:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for foo-bar.net has changed,
and the key for the corresponding IP address 127.0.0.1
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /home/user/.ssh/known_hosts:6
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Notice the line "Offending key for IP in /home/user/.ssh/known_hosts:48" in the first example, and ".../known_hosts:6" in the second, it shows the 48th (or 6th) line should be removed from $HOME/.ssh/known_hosts:

sed -i '48d' ~/.ssh/known_hosts

Ref: Remove key from known_hosts



Published

Jan 19, 2016

Last Updated

Jan 19, 2016

Category

Tech

Tags

  • key 1
  • known_hosts 1
  • ssh 23

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor