Trending News

Blog

SSH Hosts and Private Keys: The Best Way to Manage
How To

SSH Hosts and Private Keys: The Best Way to Manage 

SSh Hosts and Private Keys

You work with many remote networks on a daily basis as a server administrator. Throughout your job, you may need to SSH into systems several times. You can access several remote Linux servers with a password, and you can even access them with a private key. As a result, managing all of them might be more typical.

This article will show you the best way to manage SSH Hosts and Private Keys.

SSH configuration file yehiweb

Syntax of the Configuration File:

Multiple ssh hosts may be defined in the /.ssh/config file. Use your favorite editor, such as vi, vim, or nano, to edit the configuration file.

The following is the syntax.

1. Configure the First SSH Host

For instance, our first SSH host is running a PHP development web server with the following details: nickname php-web1, user root, port 22, and password access. In the configuration file, add the following content.

Now try SSH with the command below.

2. Configure a second SSH host

On default port 22, our second host server (php-web2) is accessible via ssh key-pair with user root. In the configuration file, add the following content.

Now try SSH with the command below.

3. Add a third SSH host server

Our third ssh host server (php-db1) is accessible via key-pair with user ubuntu on port 2222. In the configuration file, add the following content.

Now try SSH with the command below.

4. Use SSH to set up forwarding

In this setup, we must forward port 3306from our local system to remote servers (php-db1). In the configuration file, add the following content.

Now try SSH with the command below

File with Final Configuration

The following is an example of your final configuration file, /.ssh/config.

Related posts

Leave a Reply

Required fields are marked *