I have a script which runs and makes the assumption that the remote host key is in known_hosts when running some commands which use SSH.

I would like to know if there is some command that can be ran that will output the remote host key status before these scripts fire. I think there must be something more ideal than trying to start an 'ssh' session though?


You can use ssh-keyscan to retrieve the host keys of a remote host. However, I'm afraid you'll have to write a few lines of shell code to check wether you have these in your known_hosts or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.