I have built sshpass on Cygwin. It works perfectly from within a Cygwin terminal window:
sshpass -p password ssh -o StrictHostKeyChecking=no user@host
However, the exact same command from a Windows command prompt produces no output.
I tried a non-interactive command to see if that worked but it didn't:
sshpass -p password ssh -o StrictHostKeyChecking=no user@host ls
Both work fine from the Cygwin environment but not from a Windows command prompt. They do work from the Windows command prompt but there is no output. I know this because I can issue commands from a cmd.exe
window and see the effects on the remote host. Also, plain ssh
(the Cygwin one) works fine from the Windows command prompt.
How can I get output from sshpass
when used in a Windows command prompt ?
Best Answer
The reason that this does not work is due to an incompatibility in stdin/stdout redirection between cygwin and native Win32 programs but there is a wrapper program called
cygnative
which solves the problem. It allows the desired command-line to be used like this:(this works for non-interactive commands but not for interactive terminal sessions)
The original author's links to
cygnative.exe
are dead, but it is available as C source in this gist or as source and executable in this zip.I discovered this solution when trying to solve another problem, this time trying to use
rsync
over PuTTY'splink
program. I was getting an error:which led me to discover
cygnative
, but tracking it down was difficult due to the original links being dead.The problem is described here and presents the solution,
cygnative
, here, with an updated version 1.2 here.