windows 10 ssh proxycommand 报错: “posix_spawn: No such file or directory”(46)

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+密钥连接多条服务器会发现不行。暂时无法解决。

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值