When copying a directory (scp -r) with a file containing \n copying stops with cryptic message protocol error: expected control record Debug mode is more verbose about the cause: Sink: : skipping, filename contains a newline protocol error: expected control record debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: channel 0: free: client-session, nchannels 1 debug1: fd 0 clearing O_NONBLOCK debug1: fd 1 clearing O_NONBLOCK ... debug1: Exit status 1 First, newline is legal (although weird) character for a file. Second, the message doesn't help to user find what happened. Third, the copying is not skipping one file, but stops at all.
This is basically an unfixable limitation of the scp protocol. The header pretty much just "filename size modes\n" and when the filename has a newline in it the protocol breaks. You could escape the newlines (which I think I have a patch for somewhere) but then the complaint becomes "scp changed my filename". About the best that could be done is to bail or skip the file with a "don't do that, then" error when someone tries to copy a file with a newline embedded in the name.
*** This bug has been marked as a duplicate of bug 891 ***
Close resolved bugs after release.