How to copy files securely between servers using the scp (secure copy protocol) command

--

secure copy protocol

The scp command in unix systems transfers files or directories securely between a local and a remote system, or two distant systems. It employs the same authentication and security measures as the Secure Shell (SSH) protocol.

Syntax

scp [option] user@sourcehost:source user@desthost:destination
  • option — scp options include cryptography, ssh configuration, ssh port, limit, recursive copy, and so on.
  • user@sourcehost:source — source file
  • user@desthost:destination — destination file

Examples

1 — Copy a file from a local server to a remote server

scp [file_name]  remoteuser@remotehost:/remote/directory/

scp file.txt charles@10.143.90.2:/home/charles/

2 — Copy a file from a remote server to a local server

scp user@remotehost:/home/user/file_name ~/path/to/destination/
scp charles@10.143.90.2:/home/charles/file.txt ~/home/

--

--

Charles Duruaku

Software Engineer | React JS | Node JS | Ruby | Nest JS | Next JS | React Native | Typescript | Average Linux User