Submitted by HighKing on Sat, 09/14/2013 - 20:01

I just found that it's possible to configure your ssh-client on a per-host basis. So, use this for host-a and that for host-b. For a while now, I was using "ServerAliveInterval 60" in my ~/.ssh/config, to make sure ssh connections don't die after a while.

However, I have a few machines that I boot-up only when necessary and have them all configured with the same ip-address. So if I was connected to machine-a, and a day later I connect to machine-b, ssh won't connect because the host-id of that machine has changed. You can make ssh ignore the host-id with "StrictHostKeyChecking no", but you certainly don't want to disable that for all hosts...

Now, if you simply place that configuration option under a line "Host x.x.x.x" (where x.x.x.x is the hostname or ip-address of the host in question), that configuration option will only affect that specific host. An example:

Host *
ServerAliveInterval 60

StrictHostKeyChecking no

Host testserver.highking.nl
Port 1022

Me like! :-)

Source: http://www.faqs.org/docs/securing/chap15sec121.html