SCP (Secure CoPy)

SCP uses SSH credentials to copy files and directories between 2 computers. It can be used to copy:

  • From your local computer to a remote computer
  • From a remote computer to your local computer
  • Between two remote computers from your local computer

The colon : sign is used to distinguish remote computer. SCP overwrites files with the same name. Usernames used for SCP must have a read permission on source computer and write permission on target computer.

SCP local -> remote:

scp file.name remote.username@remote.ip.address:/remote.directory

To copy directory use -r switch:

scp -r local.directory.name remote.username@remote.ip.address:/remote.directory

If remote computer SSH port is different than default 22:

scp -P port.number file.name remote.username@remote.ip.address:/remote.directory

SCP remote -> local:

scp remote.username@remote.ip.address:/remote.directory/file.name /local.directory.name

SCP remote.1 -> remote.2:

scp username1@computer1.ip.address:/file.name username2@computer2.ip.address:/remote.directory

The data transfer is direct between remote computers.

Based on: linuxize.com

Leave a Comment

Tested on Ubuntu & Pop OS