when I try a scp transfer I get this error:

protocol error: bad mode

PD: I can establish a ssh connection.


So, this is a bit of question necromancy, but since I got here, and then realised what the answer was after reading the first answer, I figured I'd put this here for other wayward souls.

Because of the way scp works (over stdin/stdout over ssh AFAIK), having a naive bashrc that prints messages breaks the formatting scp is expecting, and thus the connection.

As suggested in various answers elsewhere (linked below), modifying your dot-files is usually the way to fix this:


the problem was a personalized welcome message of bash

  • 5
    So what's the solution? If you can't change the welcome message, is there a way to still scp? – Thucydides411 May 5 '14 at 16:26

Check the content of your .bashrc and .bash_login files. Make sure there's nothing that sends output to the tty.

In my case, I was running a command in my .bashrc to tell me what version of Linux I had. When I deleted that, everything worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.