SCP is a program that enables you to copy a file from one machine to another using an encrypted SSH stream. This makes sure that no-one can read or alter your data while it’s been transmitted. I regulary use this to copy files from my university to my apartment in a secure manner. You can also use SCP to pull a file remotely to your client. This basic command copies a file from your client to a remote host.
$scp report.doc username@remotehost.com:/directory/subdir
This code will connect via a secure encrypted channel. Change “host.net” to either to the domain or ip adress where you wish to store your files. You will also have to supply a username. In this case, the file will be written to the “/directory/subdir”, relative to root. Note that the you specify needs to have write access to the folder you’re trying to write to. It’s not recommended to use root user as the user for the “receiving” end.
The following code shows how to copy an entire folder recursively, IE including sub dirs.
$scp -r /path/local/directory username@remotehost.com:/path/remote/directory
I’ve now shown your how to copy a file or folder from your computer to a remote host, but what if you want pull a remote file or folder?
scp -r username@remotehost.com:/path/remote/directory /path/local/directory
You can also copy a remote file/folder to a remote host:
scp username@remotehost1.com:/path/remote/host1/file.txt username@remotehost2.com:/path/remote/host2/
You can also compress files on the fly in order to minimize the data needed to be sent. Note that this method doesn’t work well with file already compress, like a video file. It does, however, work very well for text based files or some database setup.
scp -C /path/local/directory username@remotehost.com:file.txt