VScode connects to remote server
Article Directory
download extension
Download the following three extensions
Remote-SSH
Remote - SSH: Editing Configuration Files
Remote Explorer
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
After clicking the small icon, the following options will appear at the top of the interface, selectConnect to Host
The following input box appears
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
After selection, a Host added prompt will appear in the lower right corner of the interface
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 Config
to 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.
Then click the green icon to enter the connection option , and you can see the HostName just saved , you can click to connect directly
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
After selection, if the target server can be accessed, a password input box will pop up , as shown below
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
- …
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
If you see it, Got connection
it 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
Then choose to open the folder . After selecting the specified directory, you need to enter the password again to open it successfully