Using a config file with SSH

I found this to be very much worth doing once I started spending a fair amount of time SSHing into different remote systems on a regular basis. So now I have about 18 of these for personal, and client, servers. And I have an alias for each to save a bit of typing.

# The name you want to type when you "ssh {connection}"
Host sandbox
# The IP or domain to connect to
# Who to log in as
User ubuntu
# What key file to use. This one is an Amazon pem
IdentityFile /home/mark/.pem/sandbox.pem
# This allows additional connections to share the same session
# as the first connection, which avoids have to renegotiate again
ControlMaster auto
ControlPath ~/.ssh/socket-%r@%h:%p
# Force an IPv4 connection, which will probably bite me one day
AddressFamily inet
# Recheck the host IP to the known hosts on every connection
CheckHostIP no

Except for the main functionality of having a ‘one-word’ connection with the user and password/key-file defined, the big benefit from this was adding the ControlMaster and ControlPath for multiple connections. Occasionally this backfires because if the master connection is disconnected forcibly, the other connections will drop too, but usually I’m aware of which terminal related to the master connection. So it’s still a good one for me to use.

And, of course, the man page has much more.

Leave a Comment

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