Score:0

ssh config file correct syntax of "Match host" vs "Host" to utilize actual address instead of nickname

us flag

My goal is to put in some common properties for a subset of the hosts in the config. The following two examples are close except for replacing a Host section with a Match section and destination host aliases. The first example here works as intended, if I'm matching against the nickname. However, my goal is to apply the special parameters to every host on a particular subnet. Wildcarding the Host aliases isn't actually possible because there's no uniformity to the names, and some have multiple aliases.

Host *
        ServerAliveInterval 240
        AddressFamily inet
        ForwardAgent yes
        ForwardX11 yes
        ForwardX11Trusted yes

Host server*
        IdentityFile ~/.ssh/default_id_rsa
        User remoteMe
        RequestTTY force
        RemoteCommand bash
        ProxyJump myproxy

Host myproxy 
        Hostname 10.1.2.3
        User meOnProxy
        IdentityFile ~/.ssh/meOnProxy_id_rsa

Host server01 
        Hostname 192.168.1.11

Host server02
        Hostname 192.168.1.12

Host otherserver
        Hostname 10.1.15.155
        User meOnOtherserver
        IdentityFile ~/.ssh/other_id_rsa

Hoever, I'd like to key in on the Hostname, not the Host, but the following doesn't work, the match is ignored and it hangs trying to lookup the host directly (the JumpProxy and other parameters ignored). Please help me out with Match syntax.

Host *
        ServerAliveInterval 240
        AddressFamily inet
        ForwardAgent yes
        ForwardX11 yes
        ForwardX11Trusted yes

Match host 192.168.1.*
        IdentityFile ~/.ssh/default_id_rsa
        User remoteMe
        RequestTTY force
        RemoteCommand bash
        ProxyJump myproxy

Host myproxy 
        Hostname 10.1.2.3
        User meOnProxy
        IdentityFile ~/.ssh/meOnProxy_id_rsa

Host firstserver proc11
        Hostname 192.168.1.11

Host servertwo proc12
        Hostname 192.168.1.12

Host otherserver
        Hostname 10.1.15.155
        User meOnOtherserver
        IdentityFile ~/.ssh/default_id_rsa
Score:0
my flag

Instead of:

# Wrong:
Match host 192.168.1.*

You should use:

Match host="192.168.1.*"

Use commas as a separator for multiple hosts, and use ! for negation:

Match host="!192.168.1.11,192.168.1.*,192.168.2.*"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.