Here’s a quick description of the
scp command used for securely copying files between systems on Linux and UNIX.
scp (secure copy) command can be used to copy files or even entire directories to a remote host.
scp is a replacement for the
rcp (remote copy) command. While
rcp provides the same functionality it is not encrypted and therefore not secure. The
scp command uses SSH for data transfer, providing SSH level security.
scp takes arguments in the form of
scp â€“options source destination. The most common option is the
â€“r (recursive) option which is necessary if you are using
scp on multiple files or on directories. The source and destination arguments can specify not only a path but optionally a username and hostname in the format of username
@hostname:path. If the username is omitted
scp assumes the username of the current logged in user. If the hostname is omitted scp assumes the path provided is on the current system. Typically either the source or the destination will describe a remote system; however you could use scp to move a file or files from one remote system to another.
The following example copies the file
secret.dat from user tclarkâ€™s home directory to a directory named
/backup/tclark on a server named
backup_server logging in as user terry. As indicated below, the
scp command will prompt for the password for user terry on the
backup_server when the connection is attempted.
$ scp /home/tclark/secret.dat terry@backup_server:/backup/tclark
terry@backup_server's password: password
secret.dat 100% 1011 27.6KB/s 00:00
Zach has a good article about setting up ssh with key authentication which will allow you to use the
ssh commands without a password while still maintaining security.