I run an Ubuntu desktop with a bunch of virtual servers in Virtual Box to test stuff out, etc. In the past I have also been connecting to other kinds of remote VPS Linux boxes. Currently my .ssh/known_hosts
file has a whole bunch of keys in it, most of which are not being used any more.
I want to clean up my .ssh/known_hosts
file, but how do I know which key belongs to what host? I.e. how do I know which keys I can safely remove and which ones I should leave alone?
cat ~/.ssh/known_hosts | sort -k3
. This is because ssh in many cases (and it is very unclear to me in which situations exactly) makes multiple entries for the same host, and some may have a claertext host name while others will not. When sorted, it will be obvious which host an obscure entry is for, as long as there is also a clear entry for it.