Linux and UNIX Secure Copy

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 16:29, 25 January 2016 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article is about the scp command.

The command scp is used to copy files across ssh connection. You can use scp to copy files from or to a remote host. Using ssh for data transfer provides the same authentication and same level of security as ssh.

Examples:

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

scp nicolep@remotehost.com:foobar.txt /usr/local/download

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

scp foobar.txt nicolep@remotehost.com:/usr/local/download

More examples:

Recursively copy entire directories. This will get all the web directories and sub-directories and copy to the local machine

scp -r bob@10.0.0.1:/home/httpd/html/*  /home/httpd/html

The -r is the flag for recursive

Now to copy all files in the current working directory to a remote server web directory

scp * nicolep@10.0.0.9:/var/www/html