Moving Files with SCP

SCP (Secure copy protocol) is an SSH-based tool for transferring files between machines in local and wide area networks. It is a safe and quick way to exchange data.

Copying to a Remote Machine

The following command copies the file testfile.html from the local machine to the home directory of the user student on the server with the address specified address 11.22.33. Instead of the home directory (~/), any other target can be specified:

$ scp testfile.html student@11.22.33:~/

Add the -r flag to copy a directory recursively:

$ scp -r /foo/bar student@11.22.33:~/

.. admonition:: Exercise

  Select or create a short WAV file on your local machine and copy it to your personal directory on the server using SCP.

Copying From a Remote Machine

To copy a file from a remote server, the arguments' order needs to be swapped. The dot (.) copies the data to the recent directory. Any other path can be used as target.

$ scp student@ .


Create a text file in your personal directory on the server. Copy it to your local machine using the SCP command from your local machine.