SSH Client Configuration File

SSH is an invaluable tool for system administration; there’s no better way to do it. However, people rarely use the configuration files to make their lives easier. Here’s a few pointers to help:

The SSH user configuration file is usually found at ‘.ssh/config’.

# Timeouts
Often a period of inactivity on your terminal SSH can often timeout, resulting in a frozen terminal. This is often caused by smaller routers dropping persistent connections when there’s been no packet activity. Othertimes, a network drop between the client and the server will cause the same issue. One way to get around this issue is to tell SSH to keep the connection alive by sending a ‘ping’ to the server.

In your configuration file enter the following lines:

Host *
ServerAliveInterval 60
ServerAliveCountMax 10

These instructions tell SSH to send a ping every 60 seconds and to do so until it fails for 10 attempts. This helps avoid timeout problems, and can also help to rescue damaged connections.

# Port Settings

Sometimes SSH servers have to be accessed from ports other than the default of 22. Accessing this server will mean adding a flag to the commmand to define the alternate port:

ssh -p1022

This can be avoided with the following entry in the configuration file:

Host my-server.com
Port 1022

The server can now be accessed without the port specifier:

ssh

# Shortcuts

An even easier way to access the server would be to use a shortcut defined in the configuration file. If we replace the last entry with the following:

Host my
HostName my-server.com
User root
Port 1022

Then run:

ssh my

The SSH client will effectively run ‘ssh -p1022 ’.

From 29 key presses to 6.

This entry was posted in Managed Hosting. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>