2008/09/19

SCP (follow-up to SSH)

(If you don't know how to use SSH, first read the previous post)

Another post for the first year students of UvA..

SSH starts a remote shell, enabling you to work on a computer and have full control while you're on the other side of the world (but also if you're sitting next to it, of course). A little downside is, that you - when you're physically on another pc - cannot access your local pc from within the same shell. To move files to and from remote pc's over a SSH connection, there's another tool in Linux, called SCP.

(Before copying anything using scp, you don't have to log in to a ssh server. Of course it is possible to copy anything after logging in, but in that case the "local" file is in reality the "remote" file, and the "remote" file is a file on another "remote" server.

Syntax is quite simple if you're used to ssh:
scp user@host:/path/to/sourcefile /path/to/destinationfile
of course it will work in two directions:
scp /path/to/sourcefile user@host:/path/to/destinationfile
and, instead of destinationfile you'll also be able to specify a directory:
scp user@host:/path/to/sourcefile /path/to/destinationfolder/
use of wildcards is also permitted.
scp user@host:/path/to/sourcefolder/* /path/to/destinationfolder/

So, let's copy a all .txt-files from our UvA-home directory to the directory at the pc I'm now working on:
scp scienceaccount@sremote.science.uva.nl:~/*.txt .
(the last "." stands for "current directory")

Or, copy everything in my UvA-home directory to the directory called "uva_homedir" on the PC I'm right now working on:
scp -r scienceaccount@sremote.science.uva.nl:~/* ~/uva_homedir

No comments: