$HOME/.ssh/config and host/hostname resolution how-to?

Duncan Ferguson duncan_j_ferguson at yahoo.co.uk
Wed Dec 19 22:34:39 EST 2007


Hiya,

What is the easiest way of looking up a hostname to see if it exists,  
taking into account the .ssh/config file?

If i have an entry in my file

host host1
   hostname server.domain.name

then usual OS calls won't recognise the 'alias' host1.  So, i need to  
make a call via ssh somehow to check if the name resolves without  
actually initiating a full blown 'expensive' connection to it, such  
as using 'ssh host1 true' or something (which also relies on 'true'  
being on the path, or always being installed in the same place if the  
path is provided - neither of which can be guaranteed).

I tried ssh-keyscan, but this ignores the config file (probably  
correctly), so what is the more appropriate way to perform the name  
validation?  I have tried 'ssh -n host1' which seems to work - would  
this be the best option?

I am using:

   OpenSSH_4.6p1 Debian-5build1, OpenSSL 0.9.8e 23 Feb 2007

on Etch in this instance, but the method will need to be portable.

Thanks

   Duncs


More information about the openssh-unix-dev mailing list