In daily O & M work, you often have the following operations: log on to the central control (level 1) ---> log on to the overseas central control (level 2) ----> log on to the game server (level 3 ).
This operation is very complicated, especially when transferring files to the target server, it is slightly difficult to manage. The central control server that logs on to the target server will squeeze out various temporary files, making the file distribution in the system messy. So, is there a way to log on directly from the first-level server to the third-level server or upload files? The first method we came up with was to configure a network proxy or write a script. The script uploads the file to the second-level server, and then uploads the file to the third-level server through session. Then, the second-level Server File Cache is deleted. In fact, ssh and SCP commands can be configured as proxy connections through their own parameters, mainly using the SSH proxycommand parameter, the parameter value format is "ssh second-level Server ip nc % H % P". We can see that the NC command is used internally to forward packets between the first-level and third-level servers.
Note:SSH key trust needs to be adjusted. Because of the proxy, the third-level server receives requests from the first-level server. Therefore, you need to configure the public key of the first-level server to the authorized_keys file of the third-level server.
Configuration instance:
- Server IP Address:
- Level 1 server: 10.34.10.10
- Secondary server: 10.34.11.11
- Level 3 server: 10.34.12.12
- Key Trust Relationship: 11 trust 10; 12 trust 11; 12 trust 10
- Implementation: log on to the first-level server and log on to the third-level server through SSH or SCP.
- Copy Data:
SCP-O proxycommand = "ssh 10.34.11.11 NC % H % P"./testfile.txt 10.34.12.12:/root/
- Login Server:
Ssh-O proxycommand = "ssh 10.34.11.11 NC % H % P" 10.34.12.12