SCP can be used as a secure means of copying files between hosts through the SSH (Secure Shell) protocol. The following examples assume that the SSH server and any firewalls are configured to allow connections from the host initiating the connection. By default, the SSH service listens for connections on 22.
The following demonstrates the basic syntax to upload a file from the local host to a remote host:
scp examplesource.txt username@remote.hostname.or.ip:/target/folder
To download a file from a remote host to the current working directory on the local host:
scp username@remote.hostname.or.ip:/remote/folder/examplesource.txt .
If the SSH server is listening on an alternate port (such as 2222 in the example below) the alternate port can be specified on the command line using the -P argument:
scp -P 2222 username@remote.hostname.or.ip:/remote/folder/examplesource.txt .
Using the -r (recursive) command line argument, you can transfer the contents of an entire directory and its sub-directories:
scp -r username@remote.hostname.or.ip:/remote/folder .
If you are using a Windows host and you would like to upload files to or download files from a Linux host, you can install a Windows SCP client such as WinSCP. WinSCP allows you to transfer files by dragging and dropping the files using a split-screen GUI, similar to many traditional FTP clients.