【问题标题】:Can't connect VS Code to Linux machine for remote development无法将 VS Code 连接到 Linux 机器进行远程开发
【发布时间】:2022-03-09 12:13:41
【问题描述】:

我在 VS Code 上收到此错误,但不知道为什么会失败

[15:14:59.543] Log Level: 2
[15:14:59.555] remote-ssh@0.51.0
[15:14:59.555] win32 x64
[15:14:59.560] SSH Resolver called for "ssh-remote+xx.xx.xx.xx", attempt 1
[15:14:59.561] SSH Resolver called for host: xx.xx.xx.xx
[15:14:59.561] Setting up SSH remote "xx.xx.xx.xx"
[15:14:59.621] Using commit id "0ba0ca52957102ca3527cf479571617f0de6ed50" and quality "stable" for server
[15:14:59.624] Install and start server if needed
[15:15:01.964] getPlatformForHost was canceled
[15:15:01.965] Resolver error: Connecting was canceled
[15:15:01.973] ------

【问题讨论】:

    标签: ssh visual-studio-code vscode-remote


    【解决方案1】:

    在您的settings.json 中添加一个键,如下所示。请记住将$remote_server_name 替换为您的。

        "remote.SSH.remotePlatform": {
            "$remote_server_name": "linux"
        }
    
    

    菜单:文件->首选项->设置

    或点击图标打开settings.json

    【讨论】:

    • 像魅力一样工作,太棒了,谢谢!特别是考虑到没有任何“对话框”可供您选择!
    • 谢谢老板!当以非管理员权限打开 vscode 时,我无法编辑 settings.json。但是,我尝试使用Run as Administrator,它起作用了,它问我Select the platform of remote host。选项是Linux/Windows/Mac。选择后,成功了!
    【解决方案2】:

    在您输入 user@host type/select Linux/Windows/etc 的对话框中。取决于您使用的是什么,然后输入/选择继续,然后输入远程会话的密码。

    【讨论】:

    • 谢谢。第一次不是很明显,在新窗口的顶部,您选择了操作系统目标,然后在底部窗口输入密码
    • 是的,这是真的。第一次不是很明显。这条评论有帮助!
    • 不清楚你可以在哪里选择操作系统,在你输入“连接到主机”的命令行中没有任何内容。 @grit 的回答更有用
    • 谢谢老板!但是,我第一次需要使用Run as administrator 模式打开 VS 代码。
    【解决方案3】:

    对于那些在 Windows 上遇到此错误的用户:检查您是否安装了多个 ssh 客户端。

    我的解决方法是将我的 ssh 配置添加到所有 ssh 配置文件中。 就我而言,我有一个

    • C:\Users\USER_NAME.ssh\config(这是远程扩展用来给我连接选项的那个)
    • 另一个在 C:\Program Data\ssh\ssh-config

    将我的 ssh-config 设置添加到两者后,我得到了选择虚拟主机操作系统的提示。尝试直接编辑 settings.json 文件,但我认为它会因为多个 ssh 配置而感到困惑。

    附言

    针对启用了私钥和密码的连接对其进行了测试,并且两者都可以使用。

    【讨论】:

    • 谢谢;这给了我需要的指针。除了您提到的两个配置文件位置,安装 Cygwin 后,我还必须从 Cygwin shell 编辑 ~/.ssh/config 。原来这是 VS 使用的 SSH。请记住将 IdentityFile 路径转换为使用 /cygdrive/.../path/to/private_key 的路径
    【解决方案4】:

    我遇到了类似的问题,但错误日志更大。在此之前,我删除了 python 并重新安装了它。也许这导致了问题。刚刚在 vscode 中重新安装了“Remote -SSH”扩展,它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-29
      • 2020-02-10
      • 2019-01-02
      • 1970-01-01
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多