====== How to transfer files between Linux/Mac computers using SCP from the Command Line ====== This information is provided for the [[https://www.ubuntu.com/|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** (**[[cs101:scp|SCP]]**) from the command line (**[[cs101:cli|CLI]]**) (the scp command) to securely copy files and directories between remote hosts without explicitly logging into the remote systems. The scp command uses **[[cs101:ssh|SSH]]** to transfer data, so it does requires a password or passphrase for authentication. Unlike **[[cs101:rcp|RCP]]** or **[[cs101:ftp|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. [[cs101:fqdn|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 [[http://manpages.ubuntu.com/manpages/focal/en/man1/scp.1.html|Ubuntu man pages]]