This particular guide covers one specific feature – downloading files over SSH.

There are few benefits SSH may offer in terms of downloading files:

– The connection is encrypted all the way through, so you may not worry of file transition to be compromised.

– With the help of SSH keys and aliases it’s possible to establish SSH connection without entering the password each time, so it is possible to download private files in a secure way very quickly.

– There are ample opportunities to make the whole process automatic. For instance, it’s possible to create a server-side script which would create a regular backup of your hosting account and another script on your computer which will allow to download the fresh backup to your local computer on designated time.

On Linux and OS X systems:

 OpenSSH SSH/SecSH protocol suite (which comes pre-installed with OS X and available for download for most other *nix systems) includes scp (secure copy) application which can be used to upload and download files from and to remote hosts.

Here are few examples of how to use it for:

1) uploading a file from local computer to a remote one:

scp /path/to/local/file username@hostname:/path/to/remote/file

This command can be used to upload a definite file to your account on the server:

scp -P 21098 /home/localuser/site/example.html cpanel_user@servername:/home/cpanel_user/public_html

Or this one, if entire directory should be uploaded:

scp -P 21098 -r /home/localuser/site/ cpanel_user@servername:/home/cpanel_user/public_html

2) downloading a file from a remote system to your computer:

scp username@hostname:/path/to/remote/file /path/to/local/file

This particular example can be used to download an error_log from public_html of a hosting account to your local computer:

scp -P 21098 cpanel_user@servername:/home/cpanel_user/public_html/error_log /home/localuser/logs/

NOTE: when one of the commands above is used, you will be asked to insert the password to your cPanel account (when you enter the password it is automatically hidden for the security purposes)

On Windows OS:

Windows does not have native support for SSH, but there are a few workarounds.

1) You may use native Windows command line utilities, included with Powershell command line shell.

To do that, select Start button -> click on ‘Run…‘ option; – In the command line type in powershell and press Enter

filessh4

Here is an example of the command for downloading the file from the server to your computer:

Invoke-WebRequest http://domain.com/path-to-file.zip -UseBasicParsing -OutFile local.zip

where:

http://domain.com/path-to-file.zip should be replaced with the URL to the file in question
local.zip should be replaced with the name you would like the downloaded file to be stored with. You may also specify a full path there. By default, it will be downloaded to C:\Users\your-windows-username directory.

filessh5

The Invoke-WebRequest uses HTTP protocol instead of SSH one. It’s sole resemblance to scp is that command line interface is being used as well.

This method has it’s disadvantages. First of all, the connection is not encrypted unless you have an SSL certificate and specified https:// protocol in your URL. The file should be publicly accessible, which is not acceptable in some cases. Also, the file contents are stored in memory before writing to disk, making this approach unsuitable for downloading large files.

2) Another workaround includes installing Cygwin command line interface for Windows, which features scp command.

In order to use it, do the following:

– download cygwin installation file from here
– install cygwin in your computer (do not forget to include ‘openssh’ from the ‘net’ bundle during installation process0
–  once installed, you’ll be able to run ‘scp’ command form the first part of the article using windows command line terminal (accessible via Start button -> ‘Run…‘ option -> In the command line type in cmd and press Enter)

This is it!

Need any help? Contact our HelpDesk

About Author

Leave a Reply

Your email address will not be published. Required fields are marked *