How to add configuration (~/.ssh/config) per ip?

Salvador Fandino sfandino at
Wed Nov 18 23:26:20 AEDT 2015

On 11/18/2015 11:25 AM, hubert depesz lubaczewski wrote:
> Hi,
> at work we have hundreds of machines, and for various of reasons, their
> hostnames (with domain) do not reflect their physical location.
> This means that for host "" i have to go through jump host
> "", and for "" i have to go through jump host
> "".
> which jump host should be used can be deduced by IP, but it looks that
> rules like:
> Host 10.1.*
>      ProxyCommand ssh -W %h:%p
> Are not being applied when I just:
> ssh
> Is there any way to make ssh apply rules both based on name and based on
> ip?
> I could, of course, add special rule for each hostname, but that would
> mean that my ~/.ssh/config will be huge, and constantly change (new
> hosts added, old hosts removed).

you can write a script that applies any rules you may have, or even 
query some database to generate on the fly and exec'ute the correct 

Something similar to:

   Host 10.1.*
      ProxyCommand connect-through-gateway %h %p

where "connect-through-gateway" is that script.

More information about the openssh-unix-dev mailing list