ssh config

Ashish Shakya
1 min readApr 16, 2020

Everybody like alias. It is convenient to replace long and complicated commands with a simple alias.

The basic syntax for performing remote login using ssh is:

ssh -i <path-to-private-key> <user_name>@<host_name>

Now rather than using the above method, we can create aliases for ssh. In order to create an alias for ssh, we can follow the steps below:

  1. Change the current directory to ~/.ssh
  2. Create a config file in the ~/.ssh directory usingtouch config command.
  3. Inside the config file, maintain various alias for ssh.
    (The syntax inside this file has to be strictly followed)
  4. An example is shown below:
Host <alias>
HostName <hostname:Eg:abc.com or xx.xx.xx.xx>
User <user_name>
Port 22
IdentityFile <directory of the private key>

(Note the indentation from the second line)

Eg:

Host production_site
HostName test.com
User joe
Port 22
IdentityFile ~/.ssh/id_rsa

Now we can directly login to our remote server using the simple command using alias as ssh production_site .

--

--