How to Transfer files from a Linux or Windows Server over SSH
This guide details how to transfer files over SSH. There are many benefits to doing this including enhanced security and possibilities of automation.
Linux and OS X systems
OpenSSH SSH/SecSH protocol suite includes the scp (secure copy) application which can be used to upload and download files from and to remote hosts.
1) Uploading files example.
scp /path/to/local/file username@hostname:/path/to/remote/file
scp -P 21098 /home/localuser/site/example.html cpanel_user@servername:/home/cpanel_user/public_html
or use something like this if you want to upload an entire directory.
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 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
The easiest way to transfer files within the Windows operating system is to use an application called WinSCP which is available from here .
Select the typical installation options then set up a connection to the sFTP using login details or SSH key and port number. Make sure the server you are connecting to has SSH enabled.
After connecting, you’ll get two panels with files. The one on the right shows the files on the Linux instance and it opens by default in the user’s home directory. This is /root for the root user and /home/name_of_user for other users. In the left panel you have local files listed. To navigate “one directory up” (to the parent directory) double click the first entry in that list (the icon that shows an arrow pointing upward).
For simplicity WinSCP is set up in a similar way to Windows file explorer. You can use the familiar Windows screen to drag and drop files and select multiple files by holding down the CTRL key and then clicking on the desired selections, right-clicking and selecting the desired action, etc.