How to copy a file from a remote network to the local desktop

If you know the name of the file(s) you want to copy, there is no need to ssh to the remote server before using scp to copy the file(s). This should do the trick:

scp [email protected]:~/CPUTimer.h .

This will copy the file CPUTimer.h from the home directory of rrtigga on pc35.cs.ucdavis.edu to the present working directory on the local machine.

If you would rather do the scp after using ssh to connect to pc35.cs.ucdavis.edu use scp like this:

scp ~/CPUTimer.h your_local_machine_IP_address:~/.

Substitute you local machine IP here ^^^

This will copy CPUTimer.h to the home directory of the user executing scp on the local machine.


You don't have to give an absolute path to scp — the easiest way to deal with this is to go where you want to put things and use scp [email protected]:CPUTimer.h . (. refers to the current directory), or give a relative path like Desktop. You can also use ~/Desktop to refer to the Desktop directory within your home directory from anywhere.

If you have lots of files to copy from one place, you may find rsync more convenient:

rsync -avx [email protected]:foo .

That will copy the entire "foo" directory and its contents to the current directory.


sftp is a useful alternative for transferring files and archives over SSH.

Start a connection while in your target directory and use FTP commmads to transfer files.

$ sftp user@host
Connected to host
sftp> cd /usr/local/src
sftp> pwd
Remote working directory: /usr/local/src
sftp> put file.tgz
sftp> get file.tgz