Linux and UNIX Secure Copy

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 13:31, 15 February 2018 by Admin (Talk | contribs)

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.

usage examples

Examples:

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

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

PUSH - 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


Copy a file from one remote host to another, neither file residing nor resulting on the current machine.

scp nicolep@serverone.com:/usr/local/download/foobar.txt nicolep@servertwo.com:/home/nicolep

installation

Red Hat Enterprise Linux, CentOS, Trustix

yum install openssh-clients

Debian or Ubuntu

apt-get install openssh-client