say, my ~/.ssh/config
has some line:
Host machine1
User user
HostName machine1
ProxyCommand ssh server nc %h %p 2> /dev/null
and this works properly, but the problem is that I have lot of machines
: machine1, machine2, machine3, ...
so how can I set all of them without manually copy same kind of lines
You can do that this way:
You just need to list the hosts in the
Host
line, separated by whitespace, and you can omitHostName
if it's not different from the name you gave in theHost
line. See Multiple similar entries in ssh config · U&L.To simplify it even more there are the wildcards
*
and?
available with their usual meaning, soHost machine?
would be evenly possible for your example.If your hostnames fit a pattern, you can use SSH's patterns:
You can use patterns in
~/.ssh/config
. Fromman ssh_config
:So, if you want to proxy everything in
*.example.com
, then in your~/.ssh/config
, put:Or, using
ssh
's own options, you can avoid netcat:From
man ssh
:yes, the Hostname is redundant.