VScode connects to remote server

VScode connects to remote server

download extension

Download the following three extensions

Remote-SSH

Remote - SSH: Editing Configuration Files

Remote Explorer

image-20230626145915241

Connect to server via extension

After the download is complete, a small icon as follows will appear in the lower left corner of the vscode interface

image-20230626150100613

After clicking the small icon, the following options will appear at the top of the interface, selectConnect to Host

image-20230626150249687

The following input box appears

image-20230626150945025

Enter username@ip in the input box to connect

For example, the server IP to be connected is 1.1.1.1 (example)

The user name of the account is cc

then follow the prompts to enter[email protected]

If it is the first time input , vscode will provide the configuration file saving option to save the configuration file so that the next connection can be directly selected

The first configuration file can be selected for saving

image-20230626152413867

After selection, a Host added prompt will appear in the lower right corner of the interface

image-20230626152636864

This just writes the server connection information just entered into the ssh config file , which has high flexibility, that is, the information can be changed flexibly

Its purpose is only to facilitate your connection next time, and there is no need to enter username@ip server connection information

Connect via saved configuration information

You can choose Open Configto view and modify connection information

HostName is the name of the host to be connected, which can be changed according to your own preferences

Host is the IP of the target server, must be filled in correctly

At the same time, User must also be the username of the target server.

image-20230626152926329

Then click the green icon to enter the connection option , and you can see the HostName just saved , you can click to connect directly

image-20230626153121227

Then vscode will open a new interface , which is to enter the connection to the server, as shown below, the first connection needs to judge the operating system type of the target server , here the connection is a Linux server, so choose Linux

image-20230626153526400

After selection, if the target server can be accessed, a password input box will pop up , as shown below

image-20230626153734260

If the following prompt pops up, it means that there is a problem connecting to the target server, please check:

  • Is the ip entered incorrectly?
  • Is the user name entered incorrectly?
  • Do you have access to the target server

image-20230626153900382

Definitely can't connect here, because the server doesn't exist, let alone username and access rights

Access server files after successful connection

After the connection is successful, the interface will not jump or pop up a prompt box

Only the connection information will be displayed in the terminal

image-20230626154112783

If you see it, Got connectionit means the connection is successful.

access files

Select the file icon on the left, you can see the display 已连接到远程, which is also a sign of whether the connection is successful

image-20230626164551627

Then choose to open the folder . After selecting the specified directory, you need to enter the password again to open it successfully

Guess you like

Origin blog.csdn.net/ahahayaa/article/details/131399156