LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SCP issues over SSH... can't seem to copy from remote to local. (https://www.linuxquestions.org/questions/linux-newbie-8/scp-issues-over-ssh-can%27t-seem-to-copy-from-remote-to-local-844944/)

ncn8ochaser 11-17-2010 06:57 PM

SCP issues over SSH... can't seem to copy from remote to local.
 
Code:

root:# ls
CIMG9974.jpg  CIMG9976.jpg  CIMG9978.jpg  CIMG9980.jpg  CIMG9982.jpg
CIMG9975.jpg  CIMG9977.jpg  CIMG9979.jpg  CIMG9981.jpg
vector://home/john/Pictures
root:# scp -r root@192.168.1.6:/home/john/Pictures .
root@192.168.1.6's password:
scp: /home/john/Pictures/
CIMG9979.jpg                                  100% 1883KB  1.8MB/s  00:00   
CIMG9980.jpg                                  100% 1990KB  1.9MB/s  00:01   
CIMG9981.jpg                                  100% 2029KB  2.0MB/s  00:00   
CIMG9982.jpg                                  100% 2091KB  2.0MB/s  00:01   
CIMG9974.jpg                                  100% 1989KB  1.9MB/s  00:01   
CIMG9975.jpg                                  100% 2075KB  2.0MB/s  00:00   
CIMG9976.jpg                                  100% 2069KB  2.0MB/s  00:01   
CIMG9977.jpg                                  100% 1985KB  1.9MB/s  00:01   
CIMG9978.jpg                                  100% 2035KB  2.0MB/s  00:00   
vector://home/john/Pictures
root:# ls
CIMG9974.jpg  CIMG9976.jpg  CIMG9978.jpg  CIMG9980.jpg  CIMG9982.jpg
CIMG9975.jpg  CIMG9977.jpg  CIMG9979.jpg  CIMG9981.jpg  Pictures/

Alright, long time lurker and first time poster here. I've had 99.9% of my *nix questions answered by this website, so I figured it might be helpful to come in and ask about this issue.

As you can probably tell from the output above, I'm trying to perform a recursive copy of all the files (images) contained in /home/john/Pictures to "." (which I'm assuming is the "current local directory"). I can't wrap my head around the man pages (all the brackets are confusing the crap out of me!).


Basically, I run the command and it obviously works... but it performs the copy to the current REMOTE directory. So what parameter(s) do I need to use in order to copy to my LOCAL machine?


Thanks a TON, guys! Any help is appreciated!!


EDIT: Also, I've tried to use the follow command to no avail. The prompt hangs and I have to CTRL-Z out of it.

Code:

scp -r /home/john/Pictures dividebyzer0@192.168.1.5:/home/dividebyzer0/Desktop
Where dividebyzer0@192.168.1.5 is my local machine (the one I'm using/initiating the SSH with)

It is my understanding that SCP should work as follows...

Code:

scp foobar.txt your_username@remotehost:/some/remote/directory
Although, when I try this it will still copy the files on the remote machine (to itself, basically). So it's the equivalent of running "cp".

Matir 11-17-2010 08:14 PM

SCP has no knowledge that it is being run within an SSH session. Let's say I wanted to copy some files from /home/matir/files on "Workstation" to /tmp on "Server". I could either do:

Code:

Workstation# scp -r /home/matir/files Server:/tmp
or SSH to Server, and if I am running an SSH server on Workstation, I could do:

Code:

Server# scp -r Workstation:/home/matir/files /tmp
It doesn't make much sense to run scp from a host to itself. You should generally never have the hostname/IP of the machine SCP is running on in one of the arguments to scp.

ncn8ochaser 11-17-2010 09:03 PM

Quote:

Originally Posted by Matir (Post 4162529)
SCP has no knowledge that it is being run within an SSH session. Let's say I wanted to copy some files from /home/matir/files on "Workstation" to /tmp on "Server".....

Wow, thanks a lot! That was not only well said but it also worked. :)

I was wondering though, is there any way to use SCP to copy from a remote host that you're already SSH'ed into and route the files to the box you're actually using? It seems to make sense that you could do it this way but I'm not sure.

Thanks again, though. Awesome post!

chrism01 11-18-2010 12:17 AM

The pt is that ssh simply logs you in securely to any system, inc the 'current' one.
Once you are ssh'd into system B, that is your 'local' system for that shell; don't think of it as remote.
Therefore the usual cmd applies ie

scp /somedir/file user@remote:/somedir

where remote is the system you want to put the files on. Note the remote can be any system, inc the same one you are running the cmd from.
:)

If you originally login to A and want files from B, then on A

scp user@B:/dir/file .

Also note that if 'remote' user is the same as 'current' user, then 'user@' is redundant eg from fred on A to fred on B

scp file B:/dir

and it'll ask for fred's passwd.
See auth-keys for paswordless access eg automated processes.


All times are GMT -5. The time now is 12:56 AM.