Skip to content

How to use SCP command to transfer files

SCP (secure copy) is a command-line utility that allows you to securely copy files and directories between two locations.

Syntax:

scp [-346BCpqrTv] [-c cipher] [-F ssh_config] [-i identity_file] [-J destination] [-l limit] [-o ssh_option] [-P port] [-S program] source ... target

All options are documented in man scp.

Copy files and directories between two systems

scp file.txt username@ip_address:/remote/directory

If SSH on the remote host is listening on a non-default port, specify it with -P:

scp -P 2232 file.txt username@ip_address:/remote/directory

To copy a directory recursively, use -r:

scp -r /local/directory username@ip_address:/remote/directory

Comments