SCP – Secure Copy

Updated 30-Jan-2022

scp, the secure version of cp, aka copy, is pretty great, since it is straightforward to copy one or more files or directories from any one machine to any other machine (and the command could be running on a third machine).

SCP Syntax

Note: it is best to use sudo, and full paths for everything.

Second note: for using a private key at the destination, declare that first, and then the local or login+remote file(s).

scp (-r = recursive) (-i private key) ([email protected]:directory/file) or (/local/directory/file) (-i private key) ([email protected]:directory/file) or (/local/directory/file)

  • scp
  • optional -r for recursive directory structure
  • optional -i for optional identity file aka private key
    • Use the full path for the identity file (this file needs to be local to the machine on which scp is being run
  • either a [email protected]: or a /local/directory/file for the source
    • Note that there is no slash after the colon before the first directory name on a remote location
  • either a [email protected]: or a /local/directory/file for the destination
We use cookies only for WordPress functionality, and do not use third-party analytics or tracking.