Quantcast
Viewing latest article 3
Browse Latest Browse All 10

Syntax for a Secure Copy (SCP)

SCP allows files to be copied from, to, or between different hosts. It uses SSH for data transfer and it provides the same authentication and level of security as that of SSH. Following are some example commands you can run in a terminal:

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

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

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

$ scp -P 22 foobar.txt username@remotehost.com:/path/to/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 username@remotehost.com:~

Copy the file foobar.txt from remote host remotehost1.com to remote host remotehost2.com

$ scp username@remotehost1.com:/path/to/remote/directory/foobar.txt username@remotehost2.com:/path/to/remote/directory/

Copy the folder foo from remote host remotehost1.com to local directory 

$ scp -r username@remotehost1.com:/path/to/remote/directory /path/to/local/directory/

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

$ scp -r foo username@remotehost.com:/path/to/remote/directory/bar

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

$ scp foobar.txt username@remotehost.com:/path/to/remote/directory

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

$ scp username@remotehost.com:foobar.txt /path/to/local/directory

SCP by default uses the Triple-DES cipher to encrypt the data being sent. Using the Blowfish cipher has been shown to increase speed:

$ scp -c blowfish file username@remotehost.com:~

-C option for compression can also be used to increase speed. Here is an example of using blowfish and compression:

$ scp -c blowfish -C file username@remotehost.com:~

SCP Command Options:

-r : Recursively copies the contents of source files or directories.
-p : Preserves the access time, modification time, permissions of the source files in the destination.
-q : Progress bar in not displayed
-v : verbose mode. Displays debugging messages.
-P : copy files using the specified port number.

 

Always think twice before hitting the Enter key…

 

The post Syntax for a Secure Copy (SCP) appeared first on BryMayor.com.


Viewing latest article 3
Browse Latest Browse All 10

Trending Articles