Cookies on this website

We use cookies to ensure that we give you the best experience on our website. If you click 'Accept all cookies' we'll assume that you are happy to receive all cookies and you won't see this message again. If you click 'Reject all non-essential cookies' only necessary cookies providing core functionality such as security, network management, and accessibility will be enabled. Click 'Find out more' for information on how to change your cookie settings.

How to use the scp command to transfer files

The scp commands general syntax is:

scp [-r] source destination

The -r option is only necessary when the source is a folder, and will recursively copy the folder and it's contents.

Source or destination may be local or remote, depending on whether you are pulling (source is remote) or pushing (destination is remote) the file(s)/folder(s). The source supports the use of wildcards to allow the transfer of many files/folders with similar names, in this case destination must be a folder that they will be copied to.

When specifying a local target, use the absolute or relative path to the object(s) to transfer, ~/myfile would reference the file myfile in your home folder, or ../something would reference the file/folder something in the parent of the current folder.

When specifying a remote target use


username is optional if it matches on source and destination.

path supports absolute paths or with ~ as a prefix items relative to your home folder.

When not to use scp

scp is not resumable, so if you need to transfer a very large file (or a folder with many files) you should use some alternate tool, such as rsync. It also can't easily synchronise two folders - it only support replacing existing files and adding new ones, not removing files from the target that don't exist (anymore) on the source, again use rsync for this.

scp and multi-factor authentication can be irritating as you need to enter your password and second factor every time you transfer a file/folder - if the service supports SSH certificate authentication then this can be avoided, but otherwise use sftp or a GUI app.