scp (secure copy)

In order to copy the file index.html from the local machine to vesuri.helsinki.fi the following command is needed:

scp -p /Volumes/Documents/michael/Sites/index.html jeltsch@vesuri.helsinki.fi:./public_html/index.html

The p flag preserves modification times, access times, and modes from the original file. The full path of the original file (/Volumes/Documents/michael/Sites/index.html) is of course not needed if the file is in the current directory.

In order to copy the directory "/Multimedia/TV Shows/Kids & Family" from a remote server with the IP address 192.168.0.16 to the current directory of the local machine, use the following command:

scp -r root@192.168.0.16:"/Multimedia/TV\\ Shows/Kids\\ \&\\ Family" .

Note the double back slashes to escape the white spaces in the file path! The r flag is needed because you want the complete content of the directory (recursive).

If you need to specifiy a port number, you need the capital P flag:

scp -P 22222 -v TVSeriesXY_S01E* mnmplus@192.168.0.16:/Volumes/Multimedia

Sometimes, scp is inefficient (e.g. when transferring massive amounts of small, uncompressed files). In that case, one solution is to use tar (to concatenate and compress) and then pipe the output through ssh to the other machine and decompress/untar it there:

tar cpf - server.helsinki.fi | ssh jeltsch@othermachine.helsinki.fi "tar xpf - -C /home/jeltsch/"