Recently, we need to train a model of generating countermeasure network , And then develop the interface , Had to be on a remote with a video card linux On the server , therefore , Take this opportunity to study how to use vscode For remote development .
（1） stay windows Run the command under the system command line ：ssh-keygen, Enter all the way , Will be in C:\Users\ user name .ssh Two files are generated in the directory ：id_rsa and id_rsa.pub. The former is the private key , The latter is the public key . As shown below ：
（2） Copy the contents of the public key file to the remote linux The server needs password free login in the user's home directory .ssh In the table of contents , Rename it to authorized_keys. notes ： If more than one machine logs in to linux The user in , perhaps authorized_keys file already exist , Then start a different line , Write public key content .~/.ssh The directory structure is shown below ：
（3） stay linux modify .ssh Contents and authorized_keys jurisdiction .
# chmod 700 .ssh # chmod 600 authorized_keys
（4） Test configuration success , If it works , stay windows In the system, you can log in through the following ways ：
# ssh user name @ remote server ip
As shown in the figure below , Input “Remote Developement” Find plug-ins , And then click “Install” Installation .
Next , You need to fill in the configuration , Follow the direction of the arrow in the picture below ：
This will open the configuration file , In the configuration file , For remote servers IP, user name , Public key file configuration , After filling in ,“ctrl + S” preservation . As shown below ：
If you need to develop on multiple remote servers , You can configure more than one in this configuration file Host, Note that multiple different Host name .
After completing the above configuration , Can be found in vscode Open the remote server in the . As shown below , In the configured Host In the list , The right mouse button can select to connect to the remote server in the current window , Or create a new window to connect to the remote server .
Take a new window to open a remote server , After clicking , The interface is as follows ：
In this interface , You can choose the system platform , here , We choose “linux”. after , You can choose to open the directory in the system , After opening , Will expand the tree on the left ：
After connecting to the remote server , We need to configure the interpreter for our program . Be careful , Before this step , It must be for vscode Install well Python plug-in unit . Installation method: , Open the plug-in search bar , Input “Python”, Select a search result , Click on “install” Complete the installation ：
Then you can continue to configure the compiler . Press shortcut key “ctrl + shift + P” The following screen appears , Choose the first “Python：Selectt Interpreter”.
next ,vscode Will put all of the Python The environment is shown in the form of a list , Click on the one we need ：
Here we are , All the steps have been completed , You can write a paragraph Python Code to test . As shown below ：
You can see , The output path is linux Directory on , Prove that the configuration is successful .