In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the management methods of ssh host and private key in detail, the sample code in this article is very detailed, and the detailed explanation of picture and text is easy to learn, which is very suitable for beginners.
As a system administrator, deal with multiple remote systems on a regular basis. You need to use the ssh system multiple times during your work. Many remote Linux servers are accessed through passwords, many of them through private keys. Therefore, this is more typical for managing all of this content.
Profile syntax:
We can add multiple ssh host details to the ~ / .ssh/config file. Edit the configuration file in your favorite editor, such as vi, vim, or nano.
$vi~/.ssh/config
The syntax is as follows:
Host HostName IdentityFile User Port LocalForward
1. Add the first SSH host
For example, our first ssh host is running a php development Web server with details named php-web1, user root, port 22, and can be accessed by password. Add the following to the configuration file.
Host php-web1 HostName 192.168.1.100 User root
Now try using SSH as the following command.
$ssh php-web1
2. Add a second SSH host
Our second host server (php-web2) can be accessed using the ssh key pair of user root on the default port 22. Add the following to the configuration file.
Host php-web2 HostName 192.168.1.101 IdentityFile ~ / .ssh/php-web2.pem User root
Now try using SSH as the following command.
$ssh php-web2
3. Add the third SSH host
Our third ssh host server (php-db1) runs on port 2222 and is accessible through the key pair of the user ubuntu. Add the following to the configuration file.
Host php-db1 HostName 192.168.1.110 Port 2222 IdentityFile ~ / .ssh/php-db1.pem User ubuntu
Now try using SSH as the following command.
$ssh php-db1
4. Use SSH to set forwarding
In this setup, we need to forward the local system port 3306 to the remote server (php-db1) host on port 3306. Add the following to the configuration file.
Host php-db1-mysql-tunnel HostName 192.168.1.110 Port 2222 IdentityFile ~ / .ssh/php-db1.pem LocalForward 3306 127.0.0.1 IdentityFile 3306
Now try using SSH as the following command.
$ssh php-db1-mysql-tunnel
Final configuration file
The final configuration file ~ / .ssh/config is shown below.
Host php-web1 HostName 192.168.1.100 User rootHost php-web2 HostName 192.168.1.101 IdentityFile ~ / .ssh/php-web2.pem User rootHost php-db1 HostName 192.168.1.110 Port 2222 IdentityFile ~ / .ssh/php-db1.pem User ubuntuHost php-db1-mysql-tunnel HostName 192.168.1.110 Port 2222 IdentityFile ~ / .ssh/php-db1.pem LocalForward 3306 127.0.0.1 Port 3306
After reading the contents of the appeal, have you mastered the management method of ssh host and private key? If you want to know more about it, you are welcome to follow the industry information channel. If you like this article, you might as well share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.