1 Why use a springboard machine? Springboard -> target server problem
- Some servers are deployed in the laboratory intranet environment, and we cannot directly connect with personal laptops. Therefore, generally, first connect to the springboard machine (which can be accessed by the external network environment) through ssh, and then jump to the target server (intranet environment) through ssh.
- But here comes the problem! Programming can only be done through text editing tools such as vim, and command line operations are used during training, which causes a certain degree of inconvenience.
- Before I summarized vscode’s remote connection to the server and how to log in without secrets ( [Complete process] vscode connects to a remote Linux server and login without secrets ), this is obviously a connection, if “springboard -> target server” can also configure vscode remote Connection, that will bring great convenience to our coding. So can it be achieved? The answer is yes!
- Note: Because most of the operations are consistent with the direct remote operation of vscode connection, please refer to the link given above for specific operations, so here we only introduce the key operations from the springboard to the intranet target server.
2 configure config file
We have already configured the config from ssh to the springboard machine before, so now we only need to configure the config from the springboard machine to the intranet target server:
an example config is given below:
Host JumperSever
HostName 1.1.1.1
User student1
Port 1001
Host TargetSever
HostName 2.2.2.2
User student2
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p JumperSever
3 Attention
- There should be a password in the config, but here I asked the administrator to configure the password-free connection in advance, so there is no need to write the password in the config. The configuration of the secret-free connection is divided into two steps: ① write your local machine (notebook) into the file
public key
of the springboard machineauthorized_keys
; ② write the file on your springboard machine into the filepublic key
of the target serverauthorized_keys
.
The two-step operation is almost the same. Keygen generates the public key (client-side local operation) and writes authorized_keys (admin operates on the server-side). You can still refer to this article: [ Complete process] vscode connects to a remote Linux server and logins without secrets - The key point of this cross-server configuration is:
ProxyCommand ssh -W %h:%p JumpSever
this line! ByProxyCommand ssh
pointing the springboard machine at the target server. Note that the ssh here needs to be replaced withssh.exe
the path of your local machine.
4 Remote connection, start experiment
Find the option of the target server directly on the left side of vscode, and make a remote connection:
Then select the folder you want to enter and start the experiment. The subsequent operation is exactly the same as directly using ssh for remote connection:
as you can see, I have remotely connected to the intranet target server through vscode (ssh again through the springboard machine), bingo! ! ! ⭐