windows 10 ssh proxycommand 报错: “posix_spawn: No such file or directory”
问题1
ssh使用ProxyCommand通过跳板机连接目标机,报错:
CreateProcessW failed error:2
posix_spawn: No such file or directory
如果用VS code也会报错:
...
[20:50:57.334] > CreateProcessW failed error:2
>
[20:50:57.344] > posix_spawn: No such file or directory
> 过程试图写入的管道不存在。
>
...
解决方案
将ssh改成C:\Windows\System32\OpenSSH\ssh.exe或者ssh.exe,参见这篇文章。
例如,对于下面的原始命令:
ssh -o ProxyCommand="ssh 192.168.199.6 -W %h:%p" 192.168.199.5
修改后为:
ssh -o ProxyCommand="ssh.exe 192.168.199.6 -W %h:%p" 192.168.199.5
Long Story
问题2:权限问题
vscode使用了私钥id_rsa但权限不正确。
解决方案
Linux:chmod 400 id_rsa
Windows: 在Windows中右键属性->安全->高级,删除所有继承和主体,添加->选择主体->高级…->立即查找->选择当前登录的用户并给予权限即可
问题3:MacOS
macOS报错:
[19:55:50.141] Resolver error: Error:
at Function.Create (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:130564)
at Object.t.handleInstallOutput (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:1:127671)
at Object.t.tryInstallWithLocalServer (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:102339)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async /Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:104310
at async Object.t.withShowDetailsEvent (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:109845)
at async /Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100912
at async R (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:97702)
at async Object.t.resolveWithLocalServer (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:100561)
at async Object.t.resolve (/Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:107840)
at async /Users/leonliang/.vscode/extensions/ms-vscode-remote.remote-ssh-0.55.0/out/extension.js:127:141955
[19:55:50.143] ------
解决方案
如果在mac的root下可以用Command Line+密钥连接多跳服务器,但VSCode无法用config文件连接多跳服务器。多半是/bin/bash的问题,使用/bin/bash -l, 然后使用Command Line+密钥连接多条服务器会发现不行。暂时无法解决。