LinuxQuestions.org
Register a domain and help support LQ
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 11-17-2010, 07:57 PM   #1
ncn8ochaser
LQ Newbie
 
Registered: Nov 2010
Posts: 5

Rep: Reputation: 0
Question 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".

Last edited by ncn8ochaser; 11-17-2010 at 08:07 PM.
 
Old 11-17-2010, 09:14 PM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
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.
 
1 members found this post helpful.
Old 11-17-2010, 10:03 PM   #3
ncn8ochaser
LQ Newbie
 
Registered: Nov 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Matir View Post
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!
 
Old 11-18-2010, 01:17 AM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
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.
 
  


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
Using SCP to copy to local knghtz Linux - Newbie 1 08-19-2009 02:53 PM
Why won't 'scp' let me copy to a remote computer? otter2244 Linux - Networking 7 10-05-2008 07:01 PM
SCP from remote to local?? abovenbeyond Linux - Newbie 1 06-04-2008 05:45 PM
scp: copy a file from local machine to remote machine seran Linux - Newbie 8 10-30-2007 01:23 PM
scp/ssh tail(multiple file) remote copy tpreitano Linux - General 1 08-22-2005 03:17 PM


All times are GMT -5. The time now is 07:39 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration