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

I am trying to do SSH and SCP to AWS managed instance. The public key of my machine is stored at that managed instance. There is no .pem file required. I am using the following commands.

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

But none of these are working in windows.The error says,"CreateProcessW failed error:2 posix_spawn: No such file or directory lost connection". I would mention that I am able to start ssm session to that instance using this command

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

Managed instance has linux operating system and my pc has windows. Also, in config file of .ssh directory, I've added following lines.

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

The strange thing is I am able to do both ssh and SCP in 'windows subsystem from Linux' from the same machine by using the same commands. But couldn't do that in windows command prompt. What am I doing wrong?


  • This seems to be a problem of the Windows openSSH package. In ProxyCommands it requests full path qualifiers, but better use forward slashes there!

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

    I don't use the windows openSSH anymore, instead I'm using the ssh command from git-bash to avoid all the windows problems.
    The key agent works perfect, proxyCommand/proxyJumps works, and in contrast to windows, it's reliable.