概述
Visual Studio Code Remote Development allows you to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment. You can:
Develop on the same operating system you deploy to or use larger or more specialized hardware.
Sandbox your development environment to avoid impacting your local machine configuration.
Make it easy for new contributors to get started and keep everyone on a consistent environment.
Use tools or runtimes not available on your local OS or manage multiple versions of them.
Develop your Linux-deployed applications using the Windows Subsystem for Linux.
Access an existing development environment from multiple machines or locations.
Debug an application running somewhere else such as a customer site or in the cloud.
No source code needs to be on your local machine to get these benefits. Each extension in the Remote Development extension pack can run commands and other extensions directly inside a container, in WSL, or on a remote machine so that everything feels like it does when you run locally.
先决条件
确保本机已经安装 VS CODE
安装ssh客户端
确保本机已安装 SSH client, 并且确保远程主机已安装 SSH server
win7系统可以到这里下载客户端
https://github.com/PowerShell/Win32-OpenSSH/releases
解压可用,可以用来生成密钥对,需要配置win7搜索路径,然后重启vscode,在vscode的终端中就可以使用ssh了。
先在终端中免密连下远程主机,应该没问题,才能进行下一步。
安装vscode扩展
为本机 VS CODE 安装 Remote Development 扩展
配置远程连接
配置免密登录
可参考https://blog.csdn.net/gsl371/article/details/79719776
设置远程连接参数
vscode中Ctrl + Shift + p 输入 Remote-SSH:setting… 回车
设置Remote.SSH:Show Login Terminal为true,这样可以在vscode终端中使用远程终端。
连接远程主机
安装完插件后左下角会出现一个绿色的图标,点击选择会在命令窗口弹出几个选项
编辑远程主机配置文件
选择Remote-SSH:Connect to Host->Configure SSH Hosts->选择一个config
指定一个配置文件,不要选标注的,这个是本地win7安装openssh后,用ssh-keygen产生的的目录;选择下面的那个
如果选错了,可以把生成的配置文件删除了,再按左下绿色图标,连接远程,选择刚才的配置
连接完成,会在vscode终端显示连接信息
打开远程文件
然后可以在vscode中选打开文件或文件夹,可以选择远程