LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2014, 11:40 AM   #1
noochi01
LQ Newbie
 
Registered: Nov 2013
Posts: 6

Rep: Reputation: Disabled
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
 
Old 01-22-2014, 12:58 PM   #2
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
You specify port in wrong place. The command should be
scp -oPort=RemotePort /home/localuser/localdir/Test.txt username@RemoteIP:Test.txt
 
Old 01-22-2014, 02:43 PM   #3
noochi01
LQ Newbie
 
Registered: Nov 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-22-2014, 03:08 PM   #4
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
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>/
(you don't need to specify remote filename unless you want to rename the file.)

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.
 
Old 01-22-2014, 06:51 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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).
 
Old 01-31-2014, 01:21 PM   #6
noochi01
LQ Newbie
 
Registered: Nov 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
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!
 
Old 01-31-2014, 01:39 PM   #7
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Could you post your /etc/ssh/sshd_config please.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"short read (fsck)" on disc access (failed command: READ FPDMA QUEUED) estellnb Linux - Hardware 3 02-22-2012 06:27 PM
[SOLVED] "data=writeback" in fstab mounts root partition as "read-only" holister Linux - General 7 11-28-2011 10:47 PM
Failed to overwrite statefile "Read only file-system" Bviper Linux - Networking 5 01-05-2010 08:40 PM
failed "Read Cd/Dvd Capacity" FC4 on a HP Pav8000 evans0409 Linux - Hardware 4 10-14-2005 06:50 PM
What is "read manifest failed: Success"? (RH 7.3, trouble installing RPMs) vfoo Linux - Software 1 07-06-2005 11:56 AM


All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration