3. Copying Files to or From The Remote System

To transfer files to a remote system running an SSH server use the scp command, which stands for Secure CoPy. Its syntax is as follows:

scp [options] local_path [user@]remote_host:[full_path_on_the_remote_host]

If you don't specify the user@ part, then your login on the client machine will be used. If you omit the path on the remote machine, the file will be copied on the user's home directory on the remote system. Note that the colon (:) separates the user name and the machine specification from the path on the remote machine.

To transfer files from the remote system to the local machine the syntax is as follows:

scp [options] [user@]remote_host:full_path_on_the_remote_host local_path

If the source path specifies a directory, then the -r (recursive) option is mandatory. Please refer to scp(1) for more information on scp's options.