SSH Configuration File
How to save ssh configurations to a configuration file
When regularly connecting to multiple remote systems over SSH, you’ll find that remembering all the hosts and various command-line options becomes tedious. OpenSSH allows setting up a configuration file to store different SSH options for each remote machine you connect t.
SSH Config File Location
OpenSSH client-side (in this case your personal computer) configuration file is named config
, and it is stored in the hidded .ssh
directory under your user’s home directory (i.e., ~/.ssh
)
When you use the ssh
command for the first time. The ~/.ssh
directory is automatically created. If the directory doesn’t exist on your system, create it using the command below:
By default, the SSH configuration file may not exist, so you may need to create it using the touch
command :
This file must be readable and writable only by the user and not accessible by others:
SSH Config File Structure Basics
The SSH Config File takes the following structure:
The contents of the SSH config file is organized into sections. Each section starts with the Host
directive and contains specific SSH options used when establishing a connection with the remote SSH server.
Oscar Hosts
Here we peovide a list of Oscar hosts and typical SSH configuration options. You have two options
Copy the list of hosts below directly into your SSH Config File (i.e.,
~/.ssh/config
)Keep this content in a spearate file for Oscar hosts, lets say
~/.ssh/config.oscar
and include that file in your main configuration file. In this case, the first line of~/.ssh/config
will beInclude "~/.ssh/config.oscar"
Don't forget to replace <username> with your user. Also the configuration assumes your identity key is ~/.ssh/id_rsa - if you named it anything else, please update the value. If you need to generate a key got here
Connecting to your preconfigured host
You may now connect using the shortchut notation provided by your configuration file. That is, all you need to type is:
According to the configuration above, this is equivalent to
Much shorter. Enjoy!
Last updated