What is SSH Config file and how to setup ssh config

If you’re a web developer or managing multiple sites at once and regularly connecting to these sites over SSH then you’ll find it difficult to remember all of the hosts, passwords and other configurations. This article help you solve this problem using SSH Config file.

One solution is to create a bash script for each of your host or there is one more most simplest and recommended solution to this problem. OpenSSH allows you to create a user specific configuration file for each of your remote server you ever want connect.

In this guide you’ll learn following things –

  • What is config file ?
  • Where is my config file ?
  • Structure of config file and parameters.


We assume that you’re using a macOS or a Linux system with OpenSSH client installed.

What is ssh config file ?

As the name suggests, the config file stores the configuration informations related to your SSH connections. You can create different SSH file for different users of your system.

Where is my SSH Config file located ?

OpenSSH client-side config file is stored in .ssh directory under user’s home directory with the name config.

The ~/.ssh is automatically created as soon the user runs ssh command for the first time. If it is not already created on your system, create it using the below command –

The config file may not exist so you make need to create it using the following command –

Then you’ve to change the permission of this config file. The file must be readable and writeable only by the user not by accessible by others:

Structure of ssh config file and parameters

The config file have following structure –

The contents in this files are arranged in sections also known as stanzas. Each section starts with host directive and contain specific SSH options that are used when connection is established with that particular host.

Indention is recommended to make the file more readable and understandable easily.

The SSH client reads the file section by section.

You can find the full list of ssh option using man ssh_config command or by visiting ssh_config page.

Also Check – What are Websockets ?

Author: Deepak Kumar

This is Deepak Kumar, founder of True Infosystems and of-course the chief content creator at CodingLessions.info. Started my carrier as a Freelancer and now a top-rated Freelancer at Upwork, delivered over 200 successful projects with highly positive user ratings and counting.

Leave a Reply

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