1

I have a bunch of hosts that I set aliases for in my ~/.ssh/config. They are all part of a certain domain that has certain settings:

Host apple
    GSSAPIAuthentication yes
    GssapiDelegateCredentials yes
    HostName apple-computer.example.com
    User guyincognito

Host *.example.com
    GSSAPIAuthentication yes
    PreferredAuthentications gssapi-with-mic
    GssapiDelegateCredentials yes
    User guyincognito

What I'd like to do is to just define the aliases, and then have ssh recognize that they point to example.com, and read the block with the domain settings. So like:

Host banana
    HostName banana-computer.example.com
    # Uses GSSAPIAuthentication, user name, etc. from *.example.com !

Host cherry
    HostName cherry-computer.example.com

Is there any way to avoid repeating all the settings for each alias? I would not like to put the settings in the global scope, as I also have to connect to servers that do not like GSSAPIAuthentication for example.

jdm
  • 579
  • I found a solution, check out my answer at http://unix.stackexchange.com/questions/116019/why-are-rules-not-combining-in-an-ssh-config-file/266987#266987 – Karthik T Mar 02 '16 at 07:48

1 Answers1

2

I can think of two suggestions, neither of which I have tested.

A Pattern list

Host banana
    HostName banana-computer.example.com

Host cherry
    HostName cherry-computer.example.com

Host banana,cherry
    # Uses GSSAPIAuthentication, user name, etc.

or

Extend the alias slightly, Either with a prefix or suffix, and then use a pattern match with the Host keyword for the common settings.

Host our_banana
    HostName banana-computer.example.com

Host our_cherry
    HostName cherry-computer.example.com

Host our_*
    # Uses GSSAPIAuthentication, user name, etc.
X Tian
  • 10,463