58

While I understand how to scp files to and from my server from within my home network, how can I scp a file from my server to my local machine when I am on the outside, say at Starbucks?

While I am able to scp from my local machine to my server in this scenario, I haven't figured out how to grab a file from home, using the command line. Any suggestions?

Hennes
  • 65,804
  • 7
  • 115
  • 169
user98496
  • 743

3 Answers3

89

If you can copy from your local machine to the server then to go the other way just flip the command line order of the arguments when running the command on the host.

scp [from] [to]

scp user@ip:/path/to/file /local/path/
cassepipe
  • 175
Sirex
  • 11,214
41

Copy the file "foobar.txt" from a remote host to the local host:

$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file "foobar.txt" from the local host to a remote host:

$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy the directory "foo" from the local host to a remote host's directory "bar":

$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar

Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu":

$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt your_username@rh2.edu:/some/remote/directory/

Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host:

$ scp foo.txt bar.txt your_username@remotehost.edu:~

Copy the file "foobar.txt" from the local host to a remote host using port 2264:

$ scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host:

$ scp your_username@remotehost.edu:/some/remote/directory/\{a,b,c\} .

$ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\} .

For More Information: Secure Copy

azeemigi
  • 521
0

If you wanted to secure copy to a remote location such as Dropbox or GoogleDrive then create an account with https://couchdrop.io then link your storage provider.

From there simply,

scp <filename> couchdrop-username@couchdrop.io:/Dropbox etc, if you then want to pull a file from the cloud then just reverse the two statements so;

scp couchdrop-usernmae@couchdrop.io:/Dropbox/filename ~/ - this will pull the file down to your chosen directory

Jayden
  • 1