Using scp

From gr0x0rd
Revision as of 15:47, 21 March 2011 by Gr0x0rd (talk | contribs) (→‎How do I... Using scp)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

How do I... Using scp

Files can be easily copied between any two Linux systems with working ssh services using scp, which is an abbreviation for secure copy. You can use the scp command on the source computer, destination computer, or even from a computer without any association with the files in question. To perform the operations, you will need a working user account on both the source and destination computers with sufficient read and write access to the target files and folders. Here is a page with some simple scp examples.

In a nutshell, the syntax for scp is as follows. Logically, it's a hybrid of ssh and cp syntax, as one would expect.

$ scp [-flags] source destination

If I wanted to copy all of the png files in /home/gr0x0rd/files/My Documents/icons/ from the computer teletran4 to /home/gr0x0rd/files/icons/ on the computer moonbase3, I would use the following command:

$ scp -r -P 2112 "/home/gr0x0rd/files/My Documents/icons/" gr0x0rd@moonbase3:/home/gr0x0rd/files/icons/

Notice the -r flag, which stands for recursive, since the target source is a directory, and the -P flag followed by 2112, since the ssh port on the target machine is different than the default, as recommended in this guide.