SSH and SCP failed with "CreateProcessW failed error:2 posix_spawn: No such file or directory"

SSH and SCP failed with "CreateProcessW failed error:2 posix_spawn: No such file or directory"

我正在尝试对 AWS 托管实例执行 SSH 和 SCP。我机器的 public 密钥存储在该托管实例中。不需要 .pem 文件。我正在使用以下命令。

   scp -r  username@instance-id:/pathtoremotefile localpath
   scp localfilepath  username@instance-id:~
   ssh  username@instance-id

但是其中 none 个在 windows.The 中工作,错误说,“CreateProcessW 失败 error:2 posix_spawn:没有这样的文件或目录丢失连接”。我会提到我可以使用此命令启动到该实例的 ssm 会话

   aws ssm start-session --target instance-id.

托管实例有 linux 操作系统,我的电脑有 windows。 此外,在 .ssh 目录的配置文件中,我添加了以下行。

 host i-* mi-*
ProxyCommand sh -c "aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"

奇怪的是,我可以在同一台机器上使用相同的命令在 'windows subsystem from Linux' 中执行 ssh 和 SCP。但无法在 windows 命令提示符下执行此操作。 我做错了什么?

这似乎是 Windows openSSH 包的问题。 在 ProxyCommands 中,它请求完整路径限定符,但最好在那里使用正斜杠!

ProxyCommand C:/somepath/sh.exe -c "aws ssm ...

我不再使用 windows openSSH,而是使用来自 git-bash 的 ssh 命令来避免所有 windows 问题。
关键代理工作完美,proxyCommand/proxyJumps 工作,与 windows 相比,它是可靠的。