This blog post will show you how to create an SSH config file and save an SSH connection. and a config file can simplify the process of connecting to hosts.
Using an SSH config file, we can define the remote host details and use a simple name to connect to with specifying all the connection details.
Create File
We create a config file in our .ssh directory under our home directory. Below is the full path.
/home/user/.ssh/config
If the file doesn’t exist create it using the following command.
touch /home/yourusername/.ssh/config
Create a Connection
Now that we have our SSH config file, we have to create an SSH connection inside the file. Let go ahead and create a connection, as shown below:
Host myubuntuserver HostName 192.168.0.121 User adminuser IdentityFile ~/.ssh/id_rsa.key
In the above code, I added a connection with an SSH file. If you don’t use an SSH you can remove the IdentityFile.
Connect
To connect to my host I will run the following command:
ssh myubuntuserver