Oh, so if I understand you correctly you want to create order in your .ssh/known_hosts file?
Hmm, I can think of only two things. Either split the known hosts file into multiple files, and/or, use git to handle these files. One does not exclude the other.
You can split hosts into different files using these commands (replace www.example.com with your own hosts):
ssh-keygen -R www.example.com # Remove hostname from known_hosts
ssh-keyscan -H www.example.com >> ~/.ssh/known_hosts # Add hostname to known_hosts
ssh-keygen -R www.example.com -f ~/.ssh/example_hosts # Remove hostname from example_hosts
ssh-keyscan -H www.example.com >> ~/.ssh/example_hosts # Add hostname to example_hosts
To log in to an ssh server, you can use this command, which looks for the host in the example_hosts file rather than known_hosts:
ssh -o ~/.ssh/example_hosts www.example.com
You can also add to the list of known configs in your
$HOME/.ssh/config directory. Simply edit or add the line that starts with
UserKnownHostsFile and watch the magic happen (space separated list):
UserKnownHostsFile ~/.ssh/known_hosts ~/.ssh/example_hosts
As for how to use and combine this with git, have a look at this page. In fact, I know many people that keep their entire home directory as a git repository - or atleast the configuration files portion of it. Here is a more generic tutorial video as well. It’s really smooth for 98% of your setup, but beware not to store anything sensitive like passwords, authentication keys and browser caches!