SCP from Command Line

I have used WinSCP for many years now. Its a great product, but sometimes, it is rather slow when copying/moving large files.

Instead of using WinSCP, users can initiate a file/directory transfer via the CLI. The command syntax is:

Downloading a Directory:

scp -r user@ssh.example.com:/path/to/remote/source /path/to/local/destination

Uploading a Directory:

scp -r /path/to/local/source user@ssh.example.com:/path/to/remote/destination

In the example below, I am copying a directory and its content from a remote server to my local machine.

First, open command-prompt and navigate to the directory you want to store the download files.

cd "C:destination_folder"

Then execute the following which will initiate the SCP session and copying all content from the source directory to the destination:

scp -P  -r <userid@source_domain_name:source_directory/*> .

The information between the <> needs to be provided, but the <> should not be included in the command.  Don’t forget the dot (.) at the end of the command.

The -r is for copying the source directory recursively.