User Tools

Site Tools


cs101:scpfromlinux

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:

  • Name of the account on the host computer (source_username)
  • Hostname (i.e. FQDN) of the computer on which the source file resides (source_host)
  • Name of the directory containing the source file (source_directory)
  • Filename of the source file (source_filename)

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

  • Name of the account on the destination computer (destination_username)
  • Hostname of the computer to which the source file will be copied (destination_host)
  • Name of the directory to which the source file will be copied (destination_directory)
  • Filename of the copy (destination_filename)

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

cs101/scpfromlinux.txt · Last modified: 2020/09/08 16:51 by localadmin