How can I get the hostkey of SSH for connection to a particular host?
I am currently using public-key authentication and so I do not need to key in the password. But every first time i connect to a new host, it checks the ".ssh2/hostkeys" directory to see if the host keys are found. If it's not found, then it'll generate one on the fly.
Coz currently, I want to execute ssh non-interactively and this prompting of hostkey generating is stopping my script from running non-interactively. But this only happens the first time. After that no problem coz the hostkey is generated.
So is it possible for me to generate the hostkey with a hostname and port given, before I run the ssh command? Coz I understand that the hostkey filename has the hostname and port of the target host.