KIM COMPUTER


scp (Secure Copy)

The scp command allows for secure file transfers between a local host and a remote host, or between two remote hosts. It uses the same authentication and security as ssh, providing a safe way to move data across networks.


1. Basic Usage

scp [options] source destination

2. Key Options

Option Name Description
-P [port] Port Use a specific port (Note: uppercase 'P').
-r Recursive Copy entire directories.
-i [file] Identity Path to the private key for authentication.
-C Compress Enables compression during transfer to speed up.

3. Practical Examples

① Uploading a local file to a server

scp local_file.txt dev_user@server_ip:/home/dev_user/

② Downloading a file from a server

scp admin@192.168.1.50:/etc/nginx/nginx.conf ./

③ Transferring a folder with SSH Key

scp -i ~/.ssh/id_rsa -r ./src webmaster@my-site.com:/var/www/

4. [Tip] Remember the Colon (:)

The most common mistake when using scp is forgetting the colon after the IP address or hostname. The colon tells scp that the following path is on a remote machine, not a local file with a weird name!