2019 VS Code 远程开发配置(热乎的)

声 明1 : 本人才疏学浅,用郭德纲的话说“我是一个小学生”,如有错误,欢迎讨论,请勿谩骂^_^。
声 明2 : 原创博客请在转载时保留原文链接或在文章开头加上本人博客地址,否则保留追究法律责任的权利。

资源

  1. 相关新闻:VS Code Remote 发布!开启远程开发新时代
  2. 官方帮助:https://code.visualstudio.com/docs/remote/ssh#_getting-started
  3. GitHub地址:https://github.com/microsoft/vscode (搞不定了google或者在这块提issue)

Windows安装

VS Code - Insiders下载

下载地址:传送门
在这里插入图片描述

Remote Development扩展安装

在这里插入图片描述

Openssh下载安装

参考帮助:传送门
使用PowerShell,以管理员身份启动

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

# This should return the following output:下面是返回的输出信息

Name  : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

然后,安装服务器和/或客户端功能:

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Both of these should return the following output:两个的输出信息都如下面所示

Path          :
Online        : True
RestartNeeded : False

若要在 Windows 上配置初次使用 OpenSSH 服务器,启动 PowerShell,以管理员身份,然后运行以下命令以启动 SSHD 服务:

Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. 
Get-NetFirewallRule -Name *ssh*
# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled

使用示例:

ssh username@servername

使用

  1. 打开VS Code,登陆的时候自动打开命令行窗口,通过ctrl+shift+p打开设置Remote-SSH-Settings,设置Remote.SSH:Show Login Terminal为true
    在这里插入图片描述

  2. 安装完插件后左下角会出现一个绿色的图标,点击选择会在命令窗口弹出几个选项
    在这里插入图片描述

  3. 这块可以选择一个config文件,也可以直接输入user@host(如[email protected]
    在这里插入图片描述
    当然了您也可以使用配置文件,格式如下:

    # Read more about SSH config files: https://linux.die.net/man/5/ssh_config
    Host 输入你的Host名字
        HostName 输入你的IP地址
        User 输入你的用户名
    
  4. 因为我是选的用户名和密码登陆,因此登陆后需要在命令行输入密码登陆。需要在vs code下方输入密码。这块需要连续输入好几次密码,一定要注意观看。

  5. 打开文件夹,这块点击完ok后又得在下方输入系统的密码,这点好烦
    在这里插入图片描述
    6.最终效果图
    在这里插入图片描述

后记

这块有时间再补充吧


参考:VScode Remote 远程开发与调试

猜你喜欢

转载自blog.csdn.net/yh0503/article/details/89851899