SCP (Secure Copy) is used to transfer files from one SSH enabled server to another SSH enabled server. Currently it can only be used to transfer files from one linux server to another as our windows server do not support SSH. It is useful when performing a site move from one linux server to another. Below is a description of how to use scp.

Overview

The general format for scp is:

scp source destination

Generally you use a local source and remote destination – that is, copying files from the machine you’re on to a remote machine. The more precise format for this action is:

scp /local/path/to/files user@remote_machine:/path/on/remote/machine

However you can also do the reverse – copy from a remote source to a local destination, in which case the format would be:

scp user@remote_machine:/path/on/remote/machine /local/path/to/files

Below are some more concrete examples. All examples are copying from local to remote, and therefore assume you’re already logged into the source machine . After running the command you’ll be prompted for the password for the remote user you specified

[edit]

copy a single file

1. Enter the following command:

scp file_name [email protected]:/new/path/to/file

For example, to copy index.html to a server’s ip address:

scp index.html user@ip_adress:/vservers/domain/htdocs/

[edit]

copy a group of files

1. Enter the following command:

scp file_name [email protected]:/new/path/to/file

For example, to copy all .htm files to a server using the ip address.

scp *.html user@ip_address:/vservers/domain/htdocs/

[edit]

Recursively copy a directory

1. Enter the following command:

scp -r directory_name_on_local_server [email protected]:/path/to/dir/

For example, to copy a  website to the server via ip address:

scp -r /vservers/domain user@ip_address:/vservers/ (your host name may vary)

The -r stands for recursively include subdirectories.

[edit]

More Information

For futher information about scp, type man scp on the Linux server

Leave a Reply