LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SCP from remote to local?? (https://www.linuxquestions.org/questions/linux-newbie-8/scp-from-remote-to-local-647048/)

abovenbeyond 06-04-2008 04:31 PM

SCP from remote to local??
 
Hello all,
I think I am brain farting... I would like to scp something from a remote box, to my local box. The issue is the firewall won't allow it and I can't change that.

Can't I do something like this??

scp uname@ip:/path_to_file .

I am told if the request originates from behind the firewall (the local box) I can go out get it and come back, if that make since in my terminology. Other wise I would ssh to the box and scp the file back, but that don't work.

Thanks

MensaWater 06-04-2008 04:45 PM

Yes.

scp requires a source and target. It doesn't care which is the local or the remote.

From the man page you see:
[[user@]host1:]file1 [...] [[user@]host2:]file2

This tells you that you can (but don't have to) specify user and host for either the local or the remote.

Due to this you could copy local files with scp any of the 3 ways shown below:
scp file1 file2
scp localhost:file1 localhost:file2
scp user1@localhost:file1 user1@localhost:file2

You can also copy local file to remote machine:
scp file1 user1@remotehost:file1

Or copy remote file to local machine:
scp user1@remotehost:file1 ./

By the way you only need the user@ specification if the name of the user on the two hosts is different. If you keep user UIDs in sync between systems it saves you typing in the long run (and also needing to chown files after transfers).


All times are GMT -5. The time now is 04:33 AM.