Copy files using scp from one system to remote system

Linux administrator should be familiar with CLI environment. Since GUI mode in Linux servers is not a common to be installed. SSH may the most popular protocol to enable Linux administrator to manage the servers via remote in secure way. Built-in with SSH command there is SCP command. SCP is used to copy file(s) between servers in secure way.

scp stands for secure cp (copy), which means you can copy files across ssh connection. That connection will be securely encrypted, it is a very secure way to copy files between computers. scp uses by default the port 22, and connect via an encrypted connection or secure shell connection. (ssh for short).


scp [-12346BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2


Copy one single local file to a remote destination

scp /path/to/source-file user@host:/path/to/destination-folder/
scp user@host:/path/to/source-file /path/to/destination-folder

Command copy's local fource file to remote system /path/to/destination-folder/ folder and also vice versa.

Copy one single file from a remote server to another remote server

scp user1@server1:/path/to/file user2@server2:/path/to/folder/

above command copy a file from one server to another server. This command is executed from thrid server.

Copy multiple files with one command

scp file1.txt file2.txt file3.txt

Copies multiple files with file name mentioned, to another server named

Copy all files with wildcard

scp /path/to/folder/*.ext user@server:/path/to/folder/

Command copies list of file with extension .txt with in a folder.

Copy all files in a folder recursively to a remote server

scp -r /path/to/source-folder user@server:/path/to/destination-folder/

Command copies all files and folders with-in source-folder recursively to remote server with same folder structure.

For more scp command options use man page using below man command.

man scp


Tags: SCP, Remote Copy, SSH