vsCode远程连接服务器报错提示

vsCodessh连接win10提示:Could not establish connection to “xx.xx.xx.xx"
vsCode 日志提示:Failed to parse remote port from server output

时间

2022/4/30

当前环境

  • vsCode版本:Version: 1.66.2 (Universal)Commit:
  • 当前vsCode安装的系统:mac
  • 想要连接的远程电脑:win10 LTSB精简版本
  • win10LTSB ssh环境:使用 OpenSSH-x64-v8.9.1.0.msi 进行安装的,并在Path中配置了环境变量(如果您使用的是windows 专业版本和家庭版本,您需要通过PowerShell安装 SSH客户端和服务端,参考链接win10安装Openssh),我没有用这个方法安装成功是因为精简版本的默认没有ssh功能,且使用PowerShell安装后,无法使用,所以自己在网上找的OpenSSH-x64-v8.9.1.0.msi 安装包进行安装,点击“运行”后,可以在管理器中发现 ssh 服务端和客户端在运行
  • 验证 win10 服务端的 ssh方法,cmd中输入 ssh,如下图就代表成功了

vscode 连接本地docker没有attach scode vscode connection to server_vscode


vscode 连接本地docker没有attach scode vscode connection to server_ide_02

假设你已经做好了如下配置和尝试

  1. 在Extensions中安装好了Remote -SSH(如下图)
  2. 添加了你要访问的服务器ip地址等信息,并拥有了一个config文件(如下图)
    请记住这个config文件的路径,一般为“/Users/user_name/.ssh/config”

vscode 连接本地docker没有attach scode vscode connection to server_vscode_03

vscode 连接本地docker没有attach scode vscode connection to server_服务端_04

报错日志信息:

出现Could not establish connection to “xx.xx.xx.xx”的报错弹窗后,查看下方日志报错信息(Failed to parse remote port from server output)

vscode 连接本地docker没有attach scode vscode connection to server_ssh_05

解决方法:

  1. 在左侧栏选择 远程连接 的电脑图标–>Command+Shift+p–>Remote-SSH:Settings—>回车
  2. 选择 Remote.SSH: Remote Platform,在这里将你的IP地址以及你要远程连接的环境(macOS/windows/linux)填写进去,如下图
  3. 配置完成后,重新连接就成功了~

补充当前vsCode的相关设置

  • Setting.json的内容
{
   "workbench.editorAssociations": {
       "*.ipynb": "jupyter-notebook"
   },
   "notebook.cellToolbarLocation": {
       "default": "right",
       "jupyter-notebook": "left"
   },
   "terminal.integrated.inheritEnv": false,
   "remote.SSH.defaultForwardedPorts": [
   
   ],
   "remote.SSH.remotePlatform":{
       "192.168.202.157": "windows"
   },
   
 
}

vscode 连接本地docker没有attach scode vscode connection to server_服务端_06

  • Settings的内容
  • Remote.SSH:Config File,我没有设置路径,网上很多教程说要设置config路径(/Users/user_name/.ssh/config

vscode 连接本地docker没有attach scode vscode connection to server_ssh_07


vscode 连接本地docker没有attach scode vscode connection to server_vscode_08