duane blake

Published on May 4, 2019 | Posted in How to

Setting up a SSH Config File

From time to time there are occasions where I need to SSH to a server. In the past when I was on a Windows machine I would use Putty. Now that I’m using Linux on a day to day basis. I can no longer use Putty I wasn’t to keen on using the traditional way of ssh remote_username@remote_host. As I have several servers and I don’t always have the IP Addresses and usernames to hand. So i’m going to demonstrate how to connect to server using a SSH config file.

How to create a SSH config file

Step 1

cd ~/.ssh

In the terminal enter the command above to go to the SSH folder

Step 2

touch config

The command above creates the config file. This is where we will place all the SSH connection information

Step 3

Host production
	HostName example.com
	User MYUSER
	IdentityFile /home/MYMACHINE/.ssh/KEY 

Open up the config file which we just created and add in the information above replacing the information with your server configuration and then save the file. If you need multiple instances just duplicate the host file block will your server credentials.

Step 4

ssh production

Back on the terminal enter the command above. If you added a IdentityFile you be prompted to enter your passphase key or password if you not using IdentityFile. If all worked you should be connected to your server.

As you can see this method of connecting using a SSH config file is much more easier than having to remember login credentials. Here is a list of information what can be added to your config file.

Leave a comment

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