Last week's Tip of the Trade looked at how to stop your SSH session from dropping out, using the .ssh/config file. This file can also set many other settings, either globally or on a per-host basis. Note that SSH uses the first option it encounters, so per-host options should go before global options in the file.

SSH can set a host of settings on either a global or per-host basis. Check out these especially useful ones.

SSH keys and ssh-add are useful to minimize password-typing. But you don't necessarily want to use the same key for all the machines you log onto, which requires more typing, to -i keyfile on the command line. Alternatively, you can set the identify file per host with a section like this in your ~/.ssh/config file:

Similarly, the -X and -Y command-line options enable X11 forwarding and trusted X11 forwarding, respectively. If you always want to forward X11 but only want trusted X11 for a particular machine, try this:

Host desktop.example.com ForwardX11Trusted yes Host * ForwardX11 yes

.ssh/config

User

Host longname.machine.example.com HostName lmach User julietkemp-longname

ssh lmach

ssh julietkemp-longname@longname.machine.example.com

scp

.ssh/config

You can also use thefile to set hostname abbreviations. This is useful if you regularly log into a particular machine that has an inconveniently long name. Similarly, you can use thesetting to specify the user to log in as. So:will enable me to log in to that machine simply by typingrather than. You could do something similar with a bash alias; however,will also use settings from thefile, so it's a more generalized solution.