Copy File From Remote To Local

Below are the list of commands that you can effectively use for copying file from Remote to your Local machine.

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

$ scp your_username@example.com:foobar.txt /some/local/directory

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

$ scp foobar.txt your_username@example.com:/some/remote/directory

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

$ scp -r foo your_username@example.com:/some/remote/directory/bar

Copy the file "foobar.txt" from remote host "example1.com" to remote host "example2.com"

$ scp your_username@example1.com:/some/remote/directory/foobar.txt \ your_username@example2.com:/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@example.com:~

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

$ scp -P 2264 foobar.txt your_username@example.com:/some/remote/directory

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

$ scp your_username@example.com:/some/remote/directory/\{a,b,c\} .
$ scp your_username@example.com:~/\{foo.txt,bar.txt\} .

Copy the file “db_2015_12_02-1300.zip” from a remote host to the local machine when .pem key is provided

$ scp -i path_to_pem_file your_username@example.com:path_of_zip_file /home/user_name/Desktop

Hope these list of commands comes handy at the hour of your need.

Add new comment