Last Updated: February 25, 2016
·
1.968K
· gump

Speed up SSH and name your hosts

If you're tired of SSH running slow or simply dropping the connection after a
period of inactivity - then put this in your ~/.ssh/config:

Host *
Compression yes
KeepAlive yes
TCPKeepAlive yes
ServerAliveInterval 60
CompressionLevel 9

The above settings will ensure your connection stays alive and all the traffic in and out is compressed so you use less of your bandwidth.

Named hosts

Another thing you may be likely tired of is continuously typing: ssh user@hostname.com in your terminal. You can add any number of named hosts into your ~/.ssh/config file in the following format:

Host thehost
    HostName 123.234.123.234
    User gump

User is optional if your remote username is the same as your local user. If you use the same username for logging into all your SSH hosts - you can instead put the User directive in the Host * section instead

You can also optionally add more arguments to each host, for example the pointer to any custom SSH keyfile location (if not in your default path):

IdentityFile /path/to/my/unusual/.ssh/id_rsa

Once saved - you can now log in to the server by simply typing:

$ ssh thehost

Job done!