Re:SSH Kung Fu
by mpapi on Monday April 28, 2014 @09:40AM
(#7659835)
A favorite .ssh/config feature of mine is pattern matching on hostnames with "?" and "*". So you can say something like:
and log in with e.g. "ssh bos-14".
[ Parent
| on HN ]
Yeah, 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.comThis 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.
I 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.