up vote 2 down vote favorite
share [g+] share [fb]

I have an SSH server set up on a machine which, unfortunately, changes its IP address quite often due to DHCP. I've worked around it with a small script which iterates over all the addresses for a subnet and tries to connect to each machine. The downside is that it's quite slow.

Is it possible to use the ssh command line client to connect to a machine in a subnet only if the server key matches a specific one?

link|improve this question

61% accept rate
??? Why don't you just set the server to a static IP? or connect by hostname? This is really inefficient. – caliban Sep 8 '09 at 8:47
Easy: because I can't :-) – Robert Munteanu Sep 8 '09 at 9:24
1  
You can, it's called dynamic DNS. – grawity Sep 8 '09 at 13:17
Does dynamic DNS work for private IP ranges? – Robert Munteanu Sep 8 '09 at 15:23
feedback

1 Answer

Add all the possible addresses and the server's public key to ~/.ssh/known_hosts on the client. Then set the StrictHostKeyChecking option. SSH will then refuse to connect to servers that do not match the key in the known_hosts file.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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