2

Is it possible to remove an ssh key from known_hosts both for the IP and for the FQDN of a machine, knowing only one of the 2?

For example, I am on machine A, and I want to remove the public ssh key of machine B (whose IP is 1.2.3.4) from A's known_hosts.

If I just do ssh-keygen -R 1.2.3.4, I will remove the ssh key for IP 1.2.3.4 from known_hosts. But if known_hosts also has the ssh key for B's FQDN (say, it's my.machine.b.com), then that one won't disappear (without me having to ssh-keygen -R my.machine.b.com).

Is it possible to purge known_hosts from anything regarding machine B completely, just by knowing B's IP or B's FQDN?

  • 1
    You know the host key! – Michael Hampton Oct 06 '20 at 18:51
  • Sorry, my question is probably unclear. I am asking for X, where X is a command or series of command to which I can give B's IP or B's hostname as input (just one of the two), and whose outcome is the removal of all B's pub keys from A's known_hosts. Something like an ssh-keygen -R that takes the IP but also finds and removes references to the hostname, or viceversa. – Michele Piccolini Oct 06 '20 at 20:53
  • Did you find a way? – Ákos Vandra-Meyer Jan 31 '21 at 21:22

0 Answers0