SCP | Remote File Copy Tool in the Terminal

SCP, called Secure Copy, is a file copying tool over Secure Shell (SSH) in the terminal. This is just as it says it is, to make a copy to a remote host.

Basic Syntax

scp source_file username@host:folder

Example

scp Document.pdf cubiclenate@icarus:/home/cubiclenate/Documents/.

The trailing period might be unnecessary but it just makes me feel better to use it.

Optional Parameters

-C

File compression, reduced file transfer time over the network. This of course will only work with files that are not already compressed.

-p

Preserves modification times, access times, and modes from the original file.

-r

Recursively copy entire directories. Use with caution as scp does follow symbolic links in the file tree. I’ve not tested this so I don’t know how explosive it could be.

-v

Verbose, Tells you all the things that you generally don’t need to know but nice to have when you need to debug something

Use Cases

There are many instances when I am in the terminal and I just need to fire off a file or two to a remote system. Sometimes it is far quicker and easier to just do it in terminal, since I am already there. This is not what I would consider a “file management” tool, just a way to easily push out some needed bits, then hop back to the other computer to do something with it.

Here is an example of how it was used to set up Pre-shared SSH keys.