LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 06: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 07:07 PM.
 
Old 11-17-2010, 08:14 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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, 09: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, 12:17 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:49 AM.

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
Open Source Consulting | Domain Registration