How to check if a server is in .ssh / known_hosts?

0

I have a script that syncs git repositories. If the repository has never been synchronized, the directories are created.

Eventually, when a repository is added, the server that serves the repository is not listed in the .ssh/known_hosts file and the ssh client does not proceed because it is necessary to confirm the public key's inclusion in the file.

How do I check if the server is already listed in .ssh/known_hosts ?

    
asked by anonymous 24.09.2014 / 23:00

2 answers

4

Just run the ssh-keygen -H -F <hostname> command. The command returns the line where the hostname is included, or returns nothing if it does not find.

    
24.09.2014 / 23:00
0

You can run before:

awk '{print $1}' .ssh/known_hosts 

And see what hosts are known.

    
04.10.2015 / 09:36