scp command "failed to read binary packet data!"
Hi Guys,
I'm new to linux so please bear with me... I'm using scp to copy a file from my ftp server to an ftp server outside my organization. My cert is trusted by the other server, so autehtication is not an issue. I know this becuase I can sftp to the server without any issue. Below is my example: scp /home/localuser/localdir/Test.txt -oPort=RemotePort username@RemoteIP:Test.txt When I run the above command, even with -v. -vv. or -vvv, it gets to "Sending command: scp -v -d -t Test.txt" "Received disconnect from RemoteIP:2:Failed to read binary packet data!" "lost connection" If I run sftp -oPort=RemotePort username@IP It connects every time..... Any thoughts? Thanks, Mike |
You specify port in wrong place. The command should be
scp -oPort=RemotePort /home/localuser/localdir/Test.txt username@RemoteIP:Test.txt |
Hi Pingu,
Thanks for the info, but when I tried the command as you said, I still receive... Received disconnect from RemoteIP:2:Failed to read binary packet data! lost connection |
Looking closer now, I missed one thing:
"username@RemoteIP:Test.txt" - that's not correct! It should be "username@RemoteIP://Test.txt". But then, you must have write permission in remote directory, so it's rather Code:
scp -oPort=RemotePort /home/localuser/localdir/Test.txt username@RemoteIP://home/<username>/ Another thing that can prevent scp from working is if there is a script running at every login. If so, scp will try to execute that script, fails, therefore stops and returns an error. |
It isn't that the script causes a problem. Running a script is not a problem.
What causes problems is if that script generates output to the terminal... scp runs ssh, with no pseudoterminal attached. This allows any such script to check before generating output... Any output in this situation BEFORE the file transfer occurs will cause an error as the data protocol is violated. I believe the first character sent as part of the protocol is a null byte. This null byte signals that the scp (server process) is ready for data exchange (direction is arbitrary). The client is waiting for that null byte - if something else comes in instead - you get the error. This situation occurs frequently with bashrc files that setup a terminal (things like setting status, output of a fortune string...). If this is the issue, comment out the commands starting it for testing. If the scp works, then put some kind of terminal test (one is to test for a prompt string - if no pseudoterminal is attached, the prompt string is empty/undefined). |
Update.... I tried everything possible, but was unable to get scp to fuction properly. As soon as I changed it to sftp, I was able to connect successfully. I wish I had an answer for you.
Thanks! |
Could you post your /etc/ssh/sshd_config please.
|
All times are GMT -5. The time now is 11:58 AM. |