Unix SCP – Remote Copy

The SCP command in unix is extremely useful for move files/directories from one server to another. If you log into the machine you want to transfer the files to and navigate to the directory where you want the file or directory, you can issue the following command:

To move a file: scp username@remoteserver:/home/username/example .

To move a directory: scp -r username@remoteserver:/home/username/exampledirectory .

The -r flag is to move all files/directories within the example directory. username is the remote servers user name, this can be eliminated if you want to login with the same user as you are currently logged in to the local machine with. remoteserver is the server that houses the file(s)/directory(s) you want to copy, and the “.” signifies to copy to the current location.