Wildcard in config files

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I know one can use wildcards and %h, %p etc. to simplify configuration, for

host a b c d
user myuser
hostname %h.example.com

so "ssh a" will get me to a.example.com, "ssh b" to b.example.com etc. Now I
have machines with the same names in another domain (say example.net), but
I'd like to use the same configuration pattern as above, perhaps naming the
hosts like "anet", "bnet" etc. or something like that. However, I can't do

host anet bnet cnet dnet
user myuser
hostname %h.example.net

because %h will be replaced by "anet", "bnet" etc. and those machines don't
exist (they are a.example.net b.example.net etc.). This forces me to do

host anet
user myuser
hostname a.example.net

host bnet
user myuser
hostname b.example.net

etc. which will rapidly become tedious if there are many machines. Is there
a way to somehow mangle what ends up in %h? Or of course, another way to
get what I'm trying to do?

I can of course generate the config file programmatically, but I'd like to
make sure that I'm not missing something.

Thanks in advance.

Site Timeline