Table of Contents

How to transfer files between Linux/Mac computers using SCP from the Command Line

This information is provided for the Ubuntu/Debian editions of Linux used in the CS Department. Other Linux versions may vary.

What Is SCP?

In Linux, you can use the Secure Copy Protocol (SCP) from the command line (CLI) (the scp command) to securely copy files and directories between remote hosts without explicitly logging into the remote systems. The scp command uses SSH to transfer data, so it does requires a password or passphrase for authentication. Unlike RCP or FTP, SCP encrypts both the file and any passwords exchanged so that anyone snooping on the network cannot view them.

Basic Syntax

The most basic form of the command is:

  scp [options] source_username@source_host:source_directory/source_filename destination_username@destination_host:destination_directory/destination_filename
  

The location of the source file is specified by source_username@source_host:source_directory/source_filename, which includes:

The location to which the source file will be copied is specified by destination_username@destination_host:destination_directory/destination_filename, which includes:

Options can include things like [-P port] if not connecting to the standard SSH port 22.

You can find more information on Ubuntu SCP in the Ubuntu man pages