Chapter 7. SSH Remote Connection

SSH Config File

SSH Config File
Tag:

The config file for SSH is an extremely useful tool to speed up the SSH remote login process. By writing the following information in the config file, you can shorten the SSH command.

STEP 1. Describe SSH remote login key information in the config file under the .ssh directory

Describe the following information in the config file. If the config file doesn't exist, you can create a new one.

  • Host (SSH name): you can use any name to call the SSH configuration
  • Hostname: public IP address of the server that you want to connect to
  • User: user name of the server
  • IdentityFile: full path of the private key file for SSH remote login

STEP 2. Run SSH command

Run the SSH command with the name you created

ssh [ssh name]

Practice

If you don't have the config file yet, create it in the .ssh directory. For Windows Powershell, use the New-Item command instead of the touch command.

Command Line - INPUT (Local)
cd ~/.ssh
touch config

Open the file and add the necessary information like below.

config
Host ssh_test
    Hostname 18.143.143.190
    User ubuntu
    IdentityFile ~/.ssh/id_rsa

After saving the file, run the following command.

Command Line - INPUT (Local)
ssh ssh_test

The command line may ask the passphrase if you set one. After typing the passphrase you set, you can establish an SSH connection. If you didn't set a passphrase, an SSH connection will be established right away.

Command Line - INPUT (Remote)
 

The config file for SSH is an extremely useful tool to speed up the SSH remote login process. By writing the following information in the config file, you can shorten the SSH command.

STEP 1. Describe SSH remote login key information in the config file under the .ssh directory

Describe the following information in the config file. If the config file doesn't exist, you can create a new one.

  • Host (SSH name): you can use any name to call the SSH configuration
  • Hostname: public IP address of the server that you want to connect to
  • User: user name of the server
  • IdentityFile: full path of the private key file for SSH remote login

STEP 2. Run SSH command

Run the SSH command with the name you created

ssh [ssh name]

Practice

If you don't have the config file yet, create it in the .ssh directory. For Windows Powershell, use the New-Item command instead of the touch command.

Command Line - INPUT (Local)
cd ~/.ssh
touch config

Open the file and add the necessary information like below.

config
Host ssh_test
    Hostname 18.143.143.190
    User ubuntu
    IdentityFile ~/.ssh/id_rsa

After saving the file, run the following command.

Command Line - INPUT (Local)
ssh ssh_test

The command line may ask the passphrase if you set one. After typing the passphrase you set, you can establish an SSH connection. If you didn't set a passphrase, an SSH connection will be established right away.

Command Line - INPUT (Remote)
 
Tag: