远程 SSH:“/bin/bash:没有这样的文件或目录”当尝试连接到远程服务器时
软件 | 版本 |
---|---|
客户端计算机操作系统 | Windows 10 x64 |
目标计算机操作系统 | Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64) |
VS Code | 1.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 未能成功执行此操作。我已经尝试了所有能找到的解决方法,但到目前为止没有一个有效。作为参考,我尝试过:
- 在
中的true
和false
之间切换remote.SSH.useLocalServer
C:\Users\me\AppData\Roaming\Code\User\settings.json
- 将
"PATH"
值指向C:\Program Files\Git\
和我的 VS Codeterminal.integrated.shell 中的 usr\bin
、C:\Program Files\Git\bin
或根本不存在 (""
) .windowssettings.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 扩展
我希望我会在写下这一切并回顾我的脚步的过程中弄清楚这一点,但我仍然不知所措。任何建议将不胜感激!
Software | Version |
---|---|
Client Machine OS | Windows 10 x64 |
Target Machine OS | Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64) |
VS Code | 1.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
betweentrue
andfalse
inC:\Users\me\AppData\Roaming\Code\User\settings.json
- Pointing a
"PATH"
value toC:\Program Files\Git\usr\bin
,C:\Program Files\Git\bin
, or nothing at all (""
) in theterminal.integrated.shell.windows
andterminal.integrated.shell.linux
settings in my VS Codesettings.json
, hoping it would pick upbash.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论