How to Connect the WinSCP app to Backup all Data From Linux Server?

Silicon House is a complete solution provider for reseller hosting, dedicated servers and cloud servers. Our expertise is in implementing high availability, high performance and hybrid cloud / dedicated servers.Silicon House runs hundreds of servers serving 1000+ customers in more than 90+ countries.    
In this session we are going to see, how to Connect the WinSCP app to Backup all Data From Linux Server.  Please go through the below procedure,
First of all Need to download WinSCP software to your system using the below URL.
https://winscp.net/eng/download.php

You can see a download link, Please click on it and download the installation package.

Step 1: Once the download is completed, please proceed to install the software.
Step 2: License Agreement > Click Accept
Step 3: Setup type > Typical Installation (recommended)
Step 4: Initial user settings > User interface style > Commander
Step 5: Click Install
Step 6: Click Finish

Once it is done then you can find an icon called “WinSCP” on your desktop. Open the program, “WinSCP” is installed.

Host key pair generation :
To obtain your host key, please open winSCP Icon from your desktop.

File protocol : SCP
Hostname : server IP
Port number : Server Port number
Username : root
Password : root password
Click Login

After login > Click on Session > Server and protocol information > You can see server host key fingerprints > Find SHA-256 value and copy it

So now you have obtained the Host key value. Use this key in your batch script.

More Secure method
Login to server WHM > Security Center > Manage root’s SSH Keys > Generate a New Key

Key Name (defaults to id_rsa): Enter the keyname as you wish
Key Password: Enter a password and make a note of it
Password (again):
Key Type: RSA
Key Size: 2048

Click Generate key

Go back > Manage Authorization > Authorize the key

Under private keys > View/Download key straight to the key > Enter the passphrase to convert the key to .ppk format
You will get a key format
Copy and paste it in a notepad as file.ppk format for all types

To obtain your host key, please open winSCP Icon from your desktop.

File protocol : SCP
Hostname : server IP
Port number : Server Port number
Username : root
Advanced > SSH > Authentication > choose the private key file from your local system > Click ok
Click Login

After login > Click on Session > Server and protocol information > You can see server host key fingerprints > Find SHA-256 value and copy it

So now you have obtained the Host key value. Use this key in your batch script.

Using this private key in .ppk format, you will be able to login to the server via WinSCP in a more secure way. Once you have logged in, you can see the hostkey in winSCP format which you can use in your command to connect to the server.

Copying of files from Linux Server to your Local Windows Desktop Machine using WinSCP:
Prepare the below windows batch file in your winSCP installation directory.

For eg, C:\Program Files (x86)\WinSCP

Open a Notepad, put the below command

winscp.com /ini=nul /command ^
“open scp://root@ServerIP:Port/ -hostkey=””ssh-rsa 2048 Hostkeypair””” ^
“get SOURCEDIRECTORY DESTINATIONDIRECTORY” ^
“exit”

ServerIP defines IP of the server
Port defines Port number of the server
SOURCEDIRECTORY defines the directory or path where your backups are present. For eg, /backup/cpbackup/weekly is where your weekly cpanel backups stored
DESTINATIONDIRECTORY defined the directory or path in your local system where the backup will be stored

Eg code is mentioned below,

winscp.com /ini=nul /command ^
“open scp://root@x.x.x.x:1269/ -hostkey=””ssh-rsa 2048 qISVJ4oOxnoEGlQp6HkKB7vNUMzTUFDc/yV4OBZjlN0=””” ^
“get /backup/test.txt* C:\backup\” ^

“exit”
Save the notepad at your winscp installation directory (For eg, C:\Program Files (x86)\WinSCP), ‘Filename’ “name.bat” and ‘save as type’ choose “All files” > Save

Now in the directory where the batch file presents, double click on it. A command prompt will be opening, give the root password of the server (you can simply copy the password and right click). Automatically backup will be downloaded to your local system in the specified location.

Important Note : Please maintain the basic security of your local system Latest OS, Windows firewall, Active Antivirus software etc.