Home>Article>Development Tools> A brief analysis of how to remotely connect to cloud servers in vscode
How to remotely connect to the cloud server in vscode? The following article will introduce to you how to connect to your own cloud server remotely invscode. I hope it will be helpful to you!
Deployed a small node project on my own cloud server. When encountering small changes, it is a bit troublesome to modify them locally and then upload them to the server.
So I thought that vscode can achieve remote connection. [Recommended learning: "vscode introductory tutorial"]
Plug-in: remote
First ensure that the ssh tool is installed on your terminal.
Mac can enter: ssh in the terminal. If the following picture appears, the installation is successful:
This is for Windows:
My environment is: mac m1pro
vscode installation remote plug-in
I have already installed it
After the installation is successful, an icon will appear in the sidebar, ignoring the ecs I have configured
Add your own server
First method:
Click the plus sign in the picture above
Enter the IP address of your cloud server and press Enter
Use the mouse to select the first file in the picture below
Then get the following picture
At this time, the cloud server we added appears in the box on the left side of vscode
This When we add two more configuration information: User user name, Port port number
Then you can click the folder icon in the picture below to open the connection .
Summary configuration information
ForwardAgent yes: generated by vscode itself, the problem is not big, don’t worry about it.
The second methodis to click on the small gear and then select the first file. After that, go back to the configuration file and configure it according to the configuration information in the picture above.
Advanced Configuration
What should I do if I don’t want to have to enter a password every time I connect? Answer: Create ssh key
First generate the private key and public key files encrypted by rsa.
In the terminal, cd to ~/.ssh first, and then enter: ssh-keygen -t rsa -b 4096 -f xxxx (name it yourself)
will ask you to enter the password passphrase twice. Enter everything and don’t enter anything. Otherwise, the connection cannot be successful
Then two files, the public key and the private key with your own defined name, are generated in the ~/.ssh directory.
Then copy the xxx.pub file to the .ssh folder of the server. If the server does not exist, create it yourself. Generally, centos is in the /root/ directory, that is, ~
and then execute the command: cat xxxx.pub > authorized_keys (xxx is above your own Customized file name)
Then an authorized_keys file will be generated in the current directory
Finally, configure the vscode configuration file That’s it
Now You can develop as you like.
Ultimate Advanced
For more knowledge about VSCode, please visit:vscode tutorial!
The above is the detailed content of A brief analysis of how to remotely connect to cloud servers in vscode. For more information, please follow other related articles on the PHP Chinese website!