Customizing your default SSH configuration

Richard Gray
2 min readApr 22, 2021

--

Anyone that has ever worked with Linux/*nix is familiar with SSH (Secure Shell) and its variants. For this article, we will be working with the Open Source variant OpenSSH and it’s user config file.

What is SSH?

For those that are not familiar with it, Secure Shell is suite of tools that encrypts your session between hosts. This allows you to manage hosts without worrying that someone is sniffing your session. It also gives you the ability to encrypt your file transfers between hosts with the SCP (Secure Copy) and SFTP (Secure File Transfer Protocol) clients. Both SCP and SFTP clients are typically included with the SSH package. These tools come installed by default on MacOS and are available for install on newer Windows operating systems.

The OpenSSH config file

There are two types of OpenSSH config files, a server file (usually located in at/etc/ssh/ssh_config) and the user’s which is located in their home directory under .ssh/config. The server ssh_config file is where you would put system wide configurations that all users use. This file can only be updated by an administrator of the system. The user config is something that you can create and update for yourself.

Setting your default configuration

Below is an example of some of the options you can put in your default ~/.ssh/config file. It includes everything from forcing SSH v2 (protocol), to your username (user), to setting a default key.

Host *
ForwardAgent yes
User your_username
Protocol 2
Port 22
AddKeysToAgent yes
IdentityFile /home/your_username/.ssh/id_rsa
ServerAliveInterval 120
ServerAliveCountMax 2

If you are using MacOS you will want to add the following to your Host * section:

UseKeychain yes

That will add your keys to your Keychain on your Mac.

To see details on all the available options, check your man pages (man ssh_config) on systems that support them or you can read it online at the following address:

https://linux.die.net/man/5/ssh_config

Summary

The SSH config files allow for easy customization of your SSH environment and experience. Spend some time experimenting and learning what these options can do for you.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Richard Gray
Richard Gray

Written by Richard Gray

Linux, Security, Privacy, and Crypto Geek.

No responses yet

Write a response