ssh-config by host subnet

From the ssh_config(5) Manpage:

 A pattern consists of zero or more non-whitespace characters, ‘*’ (a
 wildcard that matches zero or more characters), or ‘?’ (a wildcard that
 matches exactly one character).  For example, to specify a set of decla‐
 rations for any host in the “.co.uk” set of domains, the following pat‐
 tern could be used:

       Host *.co.uk

 The following pattern would match any host in the 192.168.0.[0-9] network
 range:

       Host 192.168.0.?

 A pattern-list is a comma-separated list of patterns.  Patterns within
 pattern-lists may be negated by preceding them with an exclamation mark
 (‘!’).  For example, to allow a key to be used from anywhere within an
 organisation except from the “dialup” pool, the following entry (in
 authorized_keys) could be used:

       from="!*.dialup.example.com,*.example.com"

So you can just use host 10.*


This line will provide the desired functionality:

Host 192.168.1.*
IdentityFile KeyFile

If you attempt to connect a server whose ip is in this subnet, you will be able to establish an ssh connection.

Tags:

Ssh