This paper is participating in the30 years of Linux”Topic essay activity

1. VScode configures the password – free login to the server

1.1 VScode Configuring Remote Login

If VScode needs to log in remotely, it needs to download and install the Remote Development plug-in. Generally, VScode will automatically install several corresponding plug-ins, as shown in the screenshot below

Then we started to configure VScode to log in to the server. The process was very simple. Once the plugin is installed, an icon with a greater than or less than sign will appear in the lower left corner of VScode. Clicking on the icon will bring up a window. The first option will open another window to connect to the server, the second will open the current window to connect to the server, and the third will open your SSH configuration file and click on it according to your needs

Click the first one and the second one will bring up your SSH configuration window with the IP you have configured for your remote-SSH connection. To Add a New server for remote login, click Add New SSH Host and Configure SSH Hosts to open your SSH configuration file again

The next step is a simple SSH remote login, which VScode hints at. Such as [email protected] is the username you need to log in to (not necessarily root, for example). @ is followed by the IP address of the server you want to connect to

Write your SSH remote login configuration into your own SSH configuration file

Host added will appear in the lower right corner of VScode. Click connet

Let you enter the password of your corresponding user on the server. After that, all you need to do is wait for VScode to connect to the remote server. The first login will take a long time to configure, so don’t worry, the login will be quick.

Once you’ve logged in, everything is simple and you can open the folder as VScode prompts for easy operation. So that’s the VScode remote login service

1.2 VScode Configure-exempt Login

If VScode does not configure the password free login server, it is quite troublesome, whether to log in again, or enter a new folder will need to enter the password. The secret free login configuration process is also very simple, consisting of three steps

1.2.1 Generating a Key Pair on the Server

Ssh-keygen = ssh-keygen = ssh-keygen = ssh-keygen = ssh-keygen = ssh-keygen = ssh-keygen

The SSH folder, if you are root, will appear under /root. Id_rsa is the generated private key, and id_rsa.pub is the public key

1.2.2 Generating a Key Pair on a Host used by yourself

The method is the same as on the server, open CMD, enter ssh-keygen, and then enter mindlessly, the host generated public and private key is not screenshots, generated public key configuration to several servers, and then in several servers to change it is very troublesome. The SSH configuration file is in system disk > User > user name. There are four main files: id_rsa is the generated private key, id_rsa.pub is the public key, config is the generated configuration file for VScode remote login. Known_hosts Records the public key of the server for remote non-secret login

Some knowledge about known_hosts

1.2.3 Copying the Public Key of a Host to a Remote Server

In the SSH configuration folder of the server, generate an authorized_keys file and copy the host public key to this file to complete VScode remote password-free login

2.VScode configures X11 forwarding to display the GUI window

When I used VScode to remotely connect the server to run the code, there was no response when the pop-up drawing window appeared all the time. After checking, I found that VScode still needs to configure X11 forwarding. This X11 configuration, is my configuration environment stepped on the deepest pit, this VScode X11 configuration blog is not many, but also a lot of pit, I and my classmates stepped on, some want you to change localhost, some also call you the Xserver software port, some are want you in VScode the some strange configuration. According to these blogs, I took a lot of detour, and it took me a week to get through it. In fact, after I got through it, I found that it was very easy to configure X11 forwarding

2.1 Install the X11 plug-in by VScode

To search for Remote X11 on the extension market, we need to install two plug-ins, one on local VScode and one on the server

After the secret free login and plug-in are installed, we open the terminal, click Output in the terminal window, and adjust the drop-down box on the right to Remote X11 and Remote X11(SSH). The following results can be seen, and the DISPLAY values are correctly displayed

If an exception occurs in this section, the following results occur

X11 forwarding is not allowed in the server configurationThe software in the picture is MobaXterm, recommended for wall cracking. Its function is similar to Xshell, but it is more powerful and more humanized. You can view files, and it also comes with Xserver

Sudo vim /etc/ssh/sshd_config can also be directly opened by the compiler. X11Forwarding yes

2.2 Downloading Xserver Software for Use together

I mainly use Xming (links), just download it and run it, don’t need to configure anything like other blogs say, and the little icon appears in the bottom right corner when it runs

Then open VScode terminal, enter the test command xclock, the hour clock appears indicates that the configuration is successful

If no, run the echo $DISPLAY command to view the DISPLAY value. Remote X11(SSH) : localhost:11.0

If no, run the export DISPLAY=”localhost:11.0″ command.The DISPLAY value must be the same as that of Remote X11(SSH)You don’t need to change anything else, just re-use the Xclock test