3

I can alias individual hosts in .ssh/config like this:

Host nickname
    Hostname host1.example.com

But sometimes I want to alias a whole domain, so as to save typing on the command line for machines on that domain:

Host *.nick
    Hostname %h.really.long.domain.example.com

That doesn't work as written, of course. Is there something that would?


Comments have suggested this question as a duplicate, but that solution doesn't work for this use case; it requires all hosts to be explicitly listed in the config file. I'm looking for a global method; I want to tell SSH 'rewrite any host of the form host???.short as host???.really.long.example.com.'

Think of it like an equivalent of sed s/.short/.really.long.etc/

Andrew
  • 1,115

1 Answers1

5

There's no way to perform a replacement in that manner, but it is possible to use CanonicalDomains to append domains to a hostname before attempting to check if they exist.

CanonicalDomains really.long.domain.example.com
CanonicalizeHostname yes

Host *.really.long.domain.example.com
    AdditionalDirectives