This is just a short reminder on setting up aliases for SSH, making it easier to connect to remote hosts you frequently use, and to be able to customise the connect on a host by host basis.
SSH Config Files
SSH itself provides the answer to my predicament via the configuration file.
In your ~/.ssh
directory you can create a config
file and store aliases to lots of different SSH connections, each with their own settings. This makes it much easier to connect to servers you use regularly.
For example:
Host client1
HostName client1.domain.tld
User foobar
IdentityFile ~/.ssh/id_rsa
FowardAgent yes
That’s a simple alias block for a connection to a fictious host. The alias is on the first line and the settings indented underneath. Although I should note that the indent isn’t required, I just prefer it for readability.
Having set this up, you can now simple type the following on the terminal prompt to connect to the host as user foobar
with the specified ssh private key file.
ssh client1
You can set up as many host blocks in the config file as you like and they can have different settings for each one. You could even resort to different private keys for each one if the requirement arose.