Scp exec request failed on channel 0

cygwin;scpssh

I am trying to SCP files from one computer to another however I get

exec request failed on channel 0".

When I use SSH however, I can get to the machine with no problems. I am using the SCP function in Cygwin if that helps.

What I found when searching online talked about the ".bashrc" file however the only one I found is "bash.bashrc".

This is the command I have used:

scp /filelocation/file user@hostname:/folderlocation

I also tried with the IP address instead of the hostname, but I have the same result.

I checked that the remote site has the SCP command.

Best Answer

To see the .bashrc file (and other files beginning with a dot) you need to do

ls -a

The simple workaround is to rename the .profile, .bashrc, .login, .bash_profile files so that they don't get included. These are known as shell startup files.

If your scp now works, the answer lies in one of those files.

Basically one of the shell startup files is sending output back and that messes up the ssl negotiation going on.

It could be as simple as sending special escape sequences to set your window title. Another culprit is the stty command.

You want to surround output to the terminal only when logged in with

if tty -s >/dev/null 2>&1; then
    # here if have a real terminal associated to send stty commands 
    # or other special escape sequences to terminal
fi
Related Question