远程 SSH:“/bin/bash:没有这样的文件或目录”当尝试连接到远程服务器时

发布于 2025-01-11 12:34:01 字数 5640 浏览 0 评论 0原文

软件版本
客户端计算机操作系统Windows 10 x64
目标计算机操作系统Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64)
VS Code1.65.0
VS Code Remote - SSH(稳定)0.76.1

我正在尝试使用 VS Code 中的远程 SSH 扩展来编辑远程服务器上的文件。在 C:\Users\me\.ssh\config 中,我配置了以下主机:

Host druid 
  HostName mydomain.com
  Port 22
  User myuser
    IdentityFile "K:\PathToKey\id_ed25519"

当尝试连接到此目标主机时,系统会提示我输入其操作系统类型,有时还会提示输入密钥的密码,然后它失败了。我得到以下输出:

[21:35:06.080] Log Level: 2
[21:35:06.082] [email protected]
[21:35:06.082] win32 x64
[21:35:06.091] SSH Resolver called for "ssh-remote+druid", attempt 1
[21:35:06.092] "remote.SSH.useLocalServer": false
[21:35:06.092] "remote.SSH.showLoginTerminal": false
[21:35:06.092] "remote.SSH.remotePlatform": {}
[21:35:06.095] "remote.SSH.path": undefined
[21:35:06.095] "remote.SSH.configFile": undefined
[21:35:06.095] "remote.SSH.useFlock": true
[21:35:06.095] "remote.SSH.lockfilesInTmp": false
[21:35:06.096] "remote.SSH.localServerDownload": auto
[21:35:06.096] "remote.SSH.remoteServerListenOnSocket": false
[21:35:06.096] "remote.SSH.showLoginTerminal": false
[21:35:06.096] "remote.SSH.defaultExtensions": []
[21:35:06.096] "remote.SSH.loglevel": 2
[21:35:06.096] "remote.SSH.enableDynamicForwarding": true
[21:35:06.097] "remote.SSH.enableRemoteCommand": false
[21:35:06.097] "remote.SSH.serverPickPortsFromRange": {}
[21:35:06.097] "remote.SSH.serverInstallPath": {}
[21:35:06.138] SSH Resolver called for host: druid
[21:35:06.138] Setting up SSH remote "druid"
[21:35:06.151] Using commit id "b52...d43" and quality "stable" for server
[21:35:06.155] Install and start server if needed
[21:35:07.663] Checking ssh with "ssh -V"
[21:35:07.709] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.543] Failed to parse remote port from server output
[21:35:10.544] Resolver error: Error: 
    at Function.Create (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:586041)
    at Object.t.handleInstallOutput (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:584693)
    at Object.t.tryInstall (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
    at async Object.t.withShowDetailsEvent (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
    at async Object.t.resolve (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
    at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[21:35:10.550] ------

我相信这些行特别指出了问题的根源:

[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory

看起来插件的代码或脚本正在尝试运行 /bin/bash (在客户端计算机上?),但它使用的是 cmd .exe 未能成功执行此操作。我已经尝试了所有能找到的解决方法,但到目前为止没有一个有效。作为参考,我尝试过:


  • 中的truefalse之间切换remote.SSH.useLocalServer C:\Users\me\AppData\Roaming\Code\User\settings.json
  • "PATH" 值指向 C:\Program Files\Git\ terminal.integrated.shell 中的 usr\binC:\Program Files\Git\bin 或根本不存在 ("") .windows 和我的 VS Code settings.json 中的 terminal.integrated.shell.linux 设置,希望它能够拾取 bash.exe,或者至少覆盖其他地方设置不正确
  • 将默认终端配置文件设置为 Git Bash 或 Ubuntu (WSL)
  • 在 Remote.SSH 设置中指定 ssh 可执行文件和配置文件的绝对路径
  • 运行 ssh -T -D 65124 druid bash中用于与远程 SSH 输出进行比较的 PowerShell 终端(给出一行:/bin/bash: No such file or directory
  • 在两台目标计算机上运行 ldd /bin/bash并在 Ubuntu WSL 终端中比较输出(相同)
  • 检查主目录中的 .vscode-server 目录以删除并重新生成,如建议的此处
  • 运行Remote-SSH :在客户端计算机上的 VS Code 命令面板中杀死主机上的 VS Code 服务器...,这可能会或可能不会与上面的解决方案执行相同的操作
  • 卸载并重新安装远程 SSH VS Code 扩展

我希望我会在写下这一切并回顾我的脚步的过程中弄清楚这一点,但我仍然不知所措。任何建议将不胜感激!

SoftwareVersion
Client Machine OSWindows 10 x64
Target Machine OSUbuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64)
VS Code1.65.0
VS Code Remote - SSH (Stable)0.76.1

I'm trying to use the Remote SSH extension in VS Code to edit files on a remote server. In C:\Users\me\.ssh\config I have the following host configured:

Host druid 
  HostName mydomain.com
  Port 22
  User myuser
    IdentityFile "K:\PathToKey\id_ed25519"

When trying to connect to this target host, I'm prompted for its OS type, then sometimes the key's password, then it fails. I get the following output:

[21:35:06.080] Log Level: 2
[21:35:06.082] [email protected]
[21:35:06.082] win32 x64
[21:35:06.091] SSH Resolver called for "ssh-remote+druid", attempt 1
[21:35:06.092] "remote.SSH.useLocalServer": false
[21:35:06.092] "remote.SSH.showLoginTerminal": false
[21:35:06.092] "remote.SSH.remotePlatform": {}
[21:35:06.095] "remote.SSH.path": undefined
[21:35:06.095] "remote.SSH.configFile": undefined
[21:35:06.095] "remote.SSH.useFlock": true
[21:35:06.095] "remote.SSH.lockfilesInTmp": false
[21:35:06.096] "remote.SSH.localServerDownload": auto
[21:35:06.096] "remote.SSH.remoteServerListenOnSocket": false
[21:35:06.096] "remote.SSH.showLoginTerminal": false
[21:35:06.096] "remote.SSH.defaultExtensions": []
[21:35:06.096] "remote.SSH.loglevel": 2
[21:35:06.096] "remote.SSH.enableDynamicForwarding": true
[21:35:06.097] "remote.SSH.enableRemoteCommand": false
[21:35:06.097] "remote.SSH.serverPickPortsFromRange": {}
[21:35:06.097] "remote.SSH.serverInstallPath": {}
[21:35:06.138] SSH Resolver called for host: druid
[21:35:06.138] Setting up SSH remote "druid"
[21:35:06.151] Using commit id "b52...d43" and quality "stable" for server
[21:35:06.155] Install and start server if needed
[21:35:07.663] Checking ssh with "ssh -V"
[21:35:07.709] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.543] Failed to parse remote port from server output
[21:35:10.544] Resolver error: Error: 
    at Function.Create (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:586041)
    at Object.t.handleInstallOutput (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:584693)
    at Object.t.tryInstall (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
    at async Object.t.withShowDetailsEvent (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
    at async Object.t.resolve (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
    at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[21:35:10.550] ------

I believe these lines in particular point to the root of the problem:

[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory

It looks like the code or script of the plugin is trying to run /bin/bash (on the client machine?), but it's using cmd.exe to do so unsuccessfully. I've tried every workaround I could find, but none have worked so far. For reference, I've tried:

  • Switching remote.SSH.useLocalServer between true and false in
    C:\Users\me\AppData\Roaming\Code\User\settings.json
  • Pointing a "PATH" value to C:\Program Files\Git\usr\bin, C:\Program Files\Git\bin, or nothing at all ("") in the terminal.integrated.shell.windows and terminal.integrated.shell.linux settings in my VS Code settings.json, hoping it would pick up bash.exe, or at least override something incorrectly set elsewhere
  • Setting the default terminal profile to either Git Bash or Ubuntu (WSL)
  • Specifying an absolute path to both the ssh executable and the config file in Remote.SSH settings
  • Running ssh -T -D 65124 druid bash in a PowerShell terminal to compare with Remote SSH output (gives one line: /bin/bash: No such file or directory)
  • Running ldd /bin/bash on both the target machine and in an Ubuntu WSL terminal to compare output (identical)
  • Checking home directories for a .vscode-server directory to delete and regenerate, as suggested here
  • Running Remote-SSH: Kill VS Code Server on Host... in the VS Code Command Palette on client machine, which may or may not do the same thing as the solution above
  • Uninstalling and reinstalling the Remote SSH VS Code extension

I was hoping that I'd figure it out in the process of writing this all down and retracing my steps, but I'm still at a loss. Any advice would be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文