Recipe 6.12 Tailoring SSH per Host
6.12.1 Problem
You want to simplify a complicated SSH
command line, or tailor SSH clients to operate differently per remote
host.
6.12.2 Solution
Create a host alias in
~/.ssh/config:
~/.ssh/config:
Host mybox
HostName mybox.whatever.example.com
User smith
...other options...
Then connect via the alias:
$ ssh mybox
6.12.3 Discussion
OpenSSH
clients obey configurations found in
~/.ssh/config. Each configuration begins with
the word Host followed by an hostname alias of your
invention.
Host work
Immediately following this line, and continuing until the next
Host keyword or end of file, place configuration
keywords and values documented on the ssh(1) manpage. In this recipe
we include the real name of the remote machine
(HostName), and the remote username
(User):
Host work
HostName mybox.whatever.example.com
User smith
Other useful keywords (there are dozens) are:
IdentityFile ~/.ssh/my_alternate_key_dsa Choose a private key file
Port 12345 Connect on an alternative port
Protocol 2 Use only the SSH-2 protocol
6.12.4 See Also
ssh_config(5) defines
the client configuration keywords.
|