SSH is great. But it does mean typing longer commands than you otherwise would have done.
For example, if your local user name is joe
but your user name on a
remote server is jbloggs
, then you have to specify the user name
whenever you use SSH to communicate with the remote server. That can
easily get annoying.
For example:
$ ssh jbloggs@someserver.example.com
That's long. Especially for lazy people. Or people who want to concentrate on what they are trying to do rather than having their brains pepped with annoying details.
You can shave some characters off the command line by configuring your
SSH client to automatically use the correct user name on the remote
servers - add this to your ~/.ssh/config
:
Server *.example.com
UserName jbloggs
Then you can reduce your command line to:
$ ssh someserver.example.com
Which is neat. And with the config fragment above, the user name
takes effect on every server in your example.com
domain.
But we can do better - by not typing ssh
at all.
The trick is to make a command named someserver.example.com
-
which then does the ssh
-ing for you. And (obviously!) somebody has
already written the script for you!
The script (actually a command, but that's splitting hairs) will look at the name it is called under, and behave exactly as if you had used the ssh
command.
A convenient place for such a command in your ~/bin
directory, as
this will be in your $PATH
already:
$ cd ~/bin
$ ln -s /usr/bin/ssh-argv0 someserver.example.com
This now gives you a command named someserver.example.com
(which
obviously still obeys your ~/.ssh/config
etc).
The end result is that you can:
$ someserver.example.com df -h
instead of:
$ ssh jbloggs@someserver.example.com df -h
As an added benefit: The fact that you now have a command named
someserver.example.com
means that the normal TAB-completion can be
used - most likely, you can get away with just typing some
followed
by TAB
and move on with your life.
Enjoy!