SCP: Secure Copy
Secure Copy, aka scp, is part of the SSH utilities that allows encrypted copying between networked systems. It has the power to copy single files or full directories. The general syntax is:
scp user1@source.host:/path/of/file user2@destination.host:/path/of/source
If user1 and user2 have the same login on both machines and it the same as that of the local machine, the names can be omitted.
- scp options that are the most useful are:
-p : Preserve modification times, access times, and modes -r : Recursively copy entire directories. -v : Be verbose for debugging.
These exercises outline some typical usage.
Exercises:
This one copies a single file from the server.acme to local:
scp server.acme:/tmp/acl.tgz . acl.tgz 100% 579KB 390.9KB/s 00:01
Copy a directory from server.acme to local, and preserve all attributes:
scp -rp server.acme:/tmp/www . blacklist.txt 100% 6160 73.4KB/s 00:00 goldlist.txt 100% 9 0.1KB/s 00:00
Same as above, but move the destination to /tmp:
scp -rp server.acme:/tmp/www /tmp/ blacklist.txt 100% 6160 73.4KB/s 00:00 goldlist.txt 100% 9 0.1KB/s 00:00
Same as above, reverse the role of source and destination: This copies the file /tmp/xyz to the server’s /tmp dir:
scp -rp /tmp/xyz server.acme:/tmp/. blacklist.txt 100% 6160 73.4KB/s 00:00 goldlist.txt 100% 9 0.1KB/s 00:00