SCP – Secure Copy

Updated 21-Nov-2021

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) (user@server:directory/file) or (/local/directory/file) (-i private key) (user@server: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 user@server: 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 user@server: or a /local/directory/file for the destination
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x