How to Use SCP to Transfer Files

SCP is an incredibly useful utility to securely transfer files from one server to another. The syntax is dead simple, to copy a remote file to your local box:

scp user@remotehost:/remotehost/filepath /localhost/filepath

Conversely, to copy a local file to a remote server:

scp /localhost/filepath user@remotehost:/remotehost/filepath

Copy a file on a remote server to another remote server:

scp user1@remotehost1:/remotehost1/filepath user2@remotehost2:/remotehost2/filepath