Malepati Phani Kumar

My Personnel Blog

What is SCP (Secure Copy) ?

on November 18, 2009

scp-secure-copySCP (a.k.a Secure Copy)

Scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.
 

Examples:

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

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

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

      $ scp file.txt your_username@remotehost:/some/remote/directory
 
Copy the file "file.txt" from the local host to a remote host whose remote host has port number

      $ scp -P <port#> file.txt your_username@remotehost:/some/remote/directory

Copy the directory "folder" from the local host to a remote host's directory "remotefolder"

      $ scp -r folder your_username@remotehost:/some/remote/directory/remotefolder

Copy the directory "folder" from the local host to a remote host's directory "remotefolder" whose remote host has port number

      $ scp -P <port#> -r folder your_username@remotehost:/some/remote/directory/remotefolder

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

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

Copy the file "file.txt" from remote host "rh1:30" to remote host "rh2:31" whose remote hosts has some port numbers.

      $ scp -P 30 your_username@rh1:/some/remote/directory/file.txt \ -P 31
      your_username@rh2:/some/remote/directory/

Copying the files "file1.txt" and "file2.txt" from the local host to your home directory on the remote host

      $ scp file1.txt file2.txt your_username@remotehost:~

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

      $ scp your_username@remotehost:/some/remote/directory/\{file1.txt,file2.txt,file3.txt\} .

Copy server1 files from server2 to server2

    $scp username@server1:/server1s/remote/directory/file.txt /server2/destination/directory


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>