Laziness: Remote SSH Usernames
I’m lazy and I’m always looking for ways to avoid any unneeded typing. Here’s a little OpenSSH configuration tip that can save you up to 16 characters (if you have crazy long usernames). When your local username doesn’t match the one on the remote server, do you find yourself routinely typing something like:
ssh ec2-user@some-aws-box.com
What if I told you that you could reduce it to just:
ssh some-aws-box.com
Edit, creating if need be, ~/.ssh/config
and add a rule like:
Host some-aws-box.com
User ec2-user
The rule is pretty much as it seems, when connecting to host
some-aws-box.com
use ec2-user
for the remote username.
The Host
line allows multiple hostnames and has limited wildcard
support, allowing rules like:
Host some-aws-box.com *.aws-domain.com
User ec2-user
Bonus, this laziness leads to even greater laziness, the stock Bash
SSH completion helper will Tab-complete a bare hostnames matching
those it finds in ~/.ssh/known_hosts
, but not one that starts starts
with a username.
What will you do with all the key strokes you save?
Comments