5 ms·
A favorite .ssh/config feature of mine is pattern matching on hostnames with "?" and "*". So you can say something like: Host bos-?? HostName %h.mydoma
by mpapi 12y ago
A favorite .ssh/config feature of mine is pattern matching on hostnames with "?" and "*". So you can say something like:
Host bos-??
HostName %h.mydomain.com
IdentityFile ~/.ssh/my-boston-key
Host nyc-??
HostName %h.mydomain2.com
IdentityFile ~/.ssh/my-nyc-key
and log in with e.g. "ssh bos-14".
- gatehouse 12y agoYeah, I use a similar thing for ec2: Host *.amazonaws.com User ec2-user IdentityFile ... And then it is just ssh ec2-X-X-X-X.compute-1.amazonaws.com
- voltagex_ 12y agoThis seems to be relatively new. It doesn't work on a couple of boxes I tried. Thanks though, I didn't know about the ?? syntax.
- mpapi 12y agoI found references to it going back to 2008, and the git repo that has my dotfiles says I've been using it (in Linux) for 3 or so years. Maybe it depends on the OS/distro. The patterns are similar to shell globs: * matches zero or more characters, ? matches exactly one.