SECURE COPY (SCP): EXAMPLES OF HOW TO USE SECURE COPY

Examples of how to use Secure Copy (scp)

scp uses ssh for data file transfer between servers and provides the same level of security as ssh.

Secure copy the file “somefile.txt” from a remote host to your local host

$ scp your_username_on_remotehost@remote_host.edu:somefile.txt /your/local/directory

 

Secure Copy your file “somefile.txt” from the local host to a remote host

$ scp somefile.txt your_username_on_remotehost@remotehost.edu:/the/remote/directory

 

Secure Copy the directory “localfoo” from your local host to a remote host’s directory “foobar”

$ scp -r localfoo your_username@remotehost.edu:/the/remote/directory/foobar

 

Copy the file “foobar.dat” from remote host “remoteh1.com” to remote host “remoteh2.com”

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

 

Copying the files “foo.dat” and “bar.dat” from yor localhost to your home directory on the remote host

$ scp foo.dat bar.dat 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 remote to your current directory on the local host

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

Or

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

 

Managing scp Performance

scp uses the Triple-DES cipher to encrypt the data being sent by default. By using Blowfish, as a cipher you may increase speed. Here is how.

$ scp -c blowfish some_file your_username@remotehost.edu:~

If you have a slow connection you can use the -C option for compression to increase speed. If your connection is not slow, then this is not very helpful as it ads to the CPU burden.

$ scp -c blowfish -C local_file your_username@remotehost.edu:~

 

Leave a Reply

Your email address will not be published.