Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to scp a file from a server to my local machine, but it is giving me this error:

protocol error: unexpected <newline>

This is my syntax:

scp user@server:/path/to/file .

It did not work on this server, but then I tried the same command on my other server, so I can only assume that it is something wrong with my server and not the syntax of the scp command.

Any ideas?

share|improve this question
    
Please post your ~/.bashrc on the server. –  quanta Nov 7 '11 at 4:13
    
Thanks for the help quanta. I edited my .bashrc just before seeing your post. The issue was that I had an echo statement in it. Thanks for the help! –  srchulo Nov 7 '11 at 4:16
    
@Miles, I tried but I have to wait 8 hours because I have a reputation of less than 100. I will post it as an answer when that time is up. –  srchulo Nov 7 '11 at 4:29

2 Answers 2

up vote 6 down vote accepted

One of your login scripts (.bashrc/.cshrc/etc.) is outputting data to the terminal when it shouldn't be. This is causing scp to error when it is connecting and getting ready to copy as it starts receiving extra data it doesn't expect. Remove output that is generated here.

You can check if your terminal is interactive and only output text by using the following code in a bashrc. Something equivalent exists for other shells as well:

if shopt -q login_shell; then
    [any code that outputs text here]
fi
share|improve this answer

Found the solution. My .bashrc file and .bash_logout were set to echo out information to me whenever I log in/out. Apparently that echoed new line was giving scp some issues. I commented out my echo statements and that did the trick!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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