scp exec request failed on channel 0

20,001

Solution 1

I agree with strobelight that this error is often from output from .bashrc (and other) bash initialization files.

There are some bash-builtin ways to test for interactive shells though: advanced bash-scripting guide reference, serverfault reference.

What I've seen most often is to test $PS1 for when to do output:

if [ "$PS1" ]; then
    echo "some message"
fi

Solution 2

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
Share:
20,001

Related videos on Youtube

balloffire
Author by

balloffire

Updated on September 17, 2022

Comments

  • balloffire
    balloffire over 1 year

    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.