ssh-keyscan – Why ssh-keyscan Does Not Read .ssh/config?

known-hostssshssh-keys

I am using ssh-keyscan in a shell script to accept keys for hosts. The hosts are identified by hostname but not in /etc/hosts. They are in ./ssh/config so I can ssh <hostname> but I can not ping etc.

It looks like ssh-keyscan is not using the .ssh/config file and that seems funny.

Can someone confirm this happens to them?

Real question: Does someone have a way to make ssh-keyscan use ~/.ssh/config?

Best Answer

ssh-keyscan doesn't and cannot be made to use .ssh/config.

However, what you are asking for doesn't require it to do so: Simply passing the real hostnames/addresses to ssh-keyscan (and thus storing them in the known_hosts) will work, even if you use the aliases from the config with ssh. But you can even instruct ssh-keyscan to add other names to the output besides those it used to connect when using the -f option:

 -f file
         Read hosts or “addrlist namelist” pairs from file, one per line.
         If - is supplied instead of a filename, ssh-keyscan will read
         hosts or “addrlist namelist” pairs from the standard input.