Article directory
overview
Vscode Microsoft's official plug-in Remote Development
supports remote access to the server for code debugging. The supported types are Container
, SSH
and WSL
. Here we mainly record the execution method of 本地vscode
adding 远程SSH服务器
host access.
deployment method
Environmental requirements
- Install vscode locally
- The local host and the remote host can be connected through SSH
Deploy password-free login for remote hosts
-
Use the local DOS command
ssh-keygen
, press Enter, andC:\User\username\.ssh
a pair of secret keyid_rsa
and key will be generated in the directoryid_rsa.pub
-
Add the public key
id_rsa.pub
to the directory of the remote host/root/.ssh
, and rename the fileauthorized_keys
. If the remote host has added password-free login of other machines, that is, the current remote host hasauthorized_keys
a file, copy the content of the public key , and paste it in the fileid_rsa.pub
of the remote host.authorized_keys
. -
Modify file permissions
chmod 700 /root/.ssh chmod 600 /root/.ssh/authorized_keys
-
Test password-free login
# 使用指令登录,根据实际环境更换user和remote_ip ssh user@remote_ip
Note: The .ssh directory is stored in the user's home directory of the operating system. For example, for the local operating system,
C:\User\Administrator
other user names need to be replaced accordingly; for remote Linux hosts,/root/.ssh
non-root users are in/home/not_root_user/.ssh
vscode plug-in installation and host connection
-
install plugin
Remote Development
-
To configure the remote host connection, click on the left navigation bar
Remote Explorer
and select the target host type asSSH Targets
-
Connect to the host address, click +, fill in the ssh connection command in the address bar on the right
ssh [email protected]
, press Enter to confirm, select the file to save the configuration, it is recommended to selectC:\User\administrator\.ssh/config
-
Open remote connection window
-
The project or project directory can be opened in a new window
-
As shown in the example, open the remote Linux host at this time
python工程
, and at the same time, you can choose远程python解释器环境
So far, the deployment of the local vscode debugging remote host code environment is completed.