使用Windows7上的VS Code打开远程机Ubuntu上的文件操作步骤

x33g5p2x  于2021-12-15 转载在 Linux  
字(1.2k)|赞(0)|评价(0)|浏览(478)

    之前在https://blog.csdn.net/fengbingchun/article/details/118991855 中介绍过在Windows10通过VS Code打开Ubuntu 16.04上的文件或文件夹的操作步骤。Windows7上的操作与Windows10有所不同,这里记录下。

    Visual Studio Code Remote - SSH扩展允许你在任何远程机器、虚拟机或具有运行SSH服务器的容器上打开远程文件夹,并充分利用VS Code的功能集。连接到服务器后,你可以与远程文件系统上任何位置的文件和文件夹进行交互。

    Windows7上系统要求:

    (1).将Windows7上的VS Code更新到最新版本。

    (2).在Windows7安装Git for Windows:从https://git-scm.com/download/win 下载并安装。

    (3).安装完Git后,会自动安装ssh.exe,将ssh.exe所在路径如D:\ProgramFiles\Git\usr\bin添加到系统环境变量中,并重启电脑。此步是为了解决可能出现的错误:”An SSH installation couldn’t be found”错误。

    (4).在Windows7上安装Visual Studio Code Remote Development Extension Pack:从https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack 点击安装。

    Ubuntu版本要求是16.04及以上版本,这里以16.04为例。在Ubuntu上安装SSH server,执行以下命令:

sudo apt-get install openssh-server

    Windows7上VS Code打开Ubuntu上的项目:

    (1).验证是否能够访问到Ubuntu:打开VS Code的Terminal,输入ssh user@ip,输入密码,看是否能够正常访问。若提示”无法将ssh项识别为cmdlet、函数、脚本文件或可运行程序的名称 …”错误时,重装VS Code即可解决。

    (2).在VS Code中按F1,输入:Remote-SSH:Connect to Host …

    (3).若没有显示Ubuntu上的ip,则点击”Add New SSH Host”,输入” ssh user@ip”及密码,选择remote host为Linux;

    (4).稍等片刻后,VS Code将连接到SSH服务器,如打开Ubuntu上的NN_Test,需要输入密码,并点击”Enter”,结果如下:

     更详细信息可参考:https://code.visualstudio.com/docs/remote/ssh

相关文章

微信公众号