scp examples

scp is used to transfer files from one machine to another. scp stands for Secure CoPy, and provides the same security as ssh (i.e., all traffic between hosts is encrypted).

To transfer a file called from the computer you are on (maybe your laptop?) to another computer called


Note the trailing dot (.) at the end of that command. That says "name the copied file the same name ( on the other computer.

Note also, the above will try to log you in on as the same user on the current computer.

So if you have username harry on the current computer, and username hpotter1 on the CS computers, you'll need to log in as user@host like this:


To copy an entire directory (myprogs), use the -r (recursive) flag:

scp -r myprogs

Finally, to go the other way and copy files from a remote machine back to your current machine, just swap the source and destination:

scp .

The above tries to copy a file called from the cs21 directory on Again, note the trailing dot (.) on that command line.

Back to SwatCS Help Docs