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

Ángel González keisial at gmail.com
Fri Nov 20 14:11:23 AEDT 2015


hubert depesz lubaczewski wrote:
> 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).

Remember that you can use shell commands. So, assuming from your example 
that the second IP octet determines the jump host, you could do:

Host *.bb.cc
  ProxyCommand ssh -W %h:%p jump$(dig +short %h|cut -d. -f 2).bb.cc


Best regards



More information about the openssh-unix-dev mailing list