scp - Secure Copy
Sep 16, 2015
scp or secure copy is a program that allows you to transfer files to/from another machine via SSH. You can think of it as the
cp command with SSH added to it. It should be available on all *nix based systems and is available on cygwin if you install it.
Copy a Local File
This command copies a local file to a remote server using
scp /your/file/name [email protected]:/remote/path/
Copy a Remote File
And of course, you can copy remote files to your local machine.
scp [email protected]:/your/file/name .
The “.” at the end will download the file to the current folder.
SSH keys can also be used by specifying the
-i <path> argument to the beginning of the command.
scp -i /path/to/key [email protected]:/your/file/name .
If SSH is running on a port other than
22, you can specify it at the beginning just like the key file. With
scp, the port argument must be capitalized (P) and cannot be lowercase (p) like it is with
scp -P 222 [email protected]:/your/file/name .
Sometimes it can be useful to upload every file in multiple directories recursively. Simply add
-r to the command.
scp -r /your/directory/path [email protected]:/remote/path/