Copy files from/to remote server using PuTTY pscp

Image from google

PuTTY is a free and open-source terminal emulator and network file transfer application. This application helps us to handle server environment with commands on the Linux operating system.

In this article, we will see how to transfer files from localhost to server or vice a versa on Linux operating system. For that, you need to install PuTTY and PSCP( PuTTY Secure Copy client to transfer files using SSH) as per your machine configuration. Link below

Image from putty.org

Once you install and setup PuTTY application you need to login to your server with hostname and port number details. Install PSCP as well and login to PuTTY terminal.

Transferring file from localhost to server

//Open a command prompt on your local machine and navigate to your file location
cd file_location
//To check files present in current directory
dir
//Now transfering file from localhost to remote server
pscp -P 22 filename_from_localhost root@server_ip_address:/server_folder_location
eg.
pscp -P 22 Library_Management.zip root@93.100.111.222:/var/www/Library_Management_Project/public_html/

Here 22 is a port number which is common in most of the cases. You can transfer files as well as zip folder. In my case, I am sending entire application files through the zip folder. Once you run this command, it will prompt for the password and you need to enter SSH password over here. Zip file will copy inside public_html folder at the remote server location.

It will show you the progress of file transferring, once it reaches 100% you can check that file using PuTTY by going to that folder and checking all files by typing

ls

Transferring file from server to localhost

//Open command prompt on local machine and change location where you want server file to download
cd folder_location
//For transfering file from remote server to localhost
pscp -P 22 root@server_ip_address:/server_folder_location/filename.extension filename.extension

It will ask for the password. Provide SSH password and file will start downloading to the folder location where your common prompt is pointing.

Bonus point

If you pull zip file, then unzip it and delete it after all files are deployed to a remote location

//Unzip folder
unzip latest.zip
//Delete zip folder
unlink folder.zip or rm folder.zip

Hopefully, you guys are clear about the file transfer process. Check out my other articles as well.

ENJOY CODING 🥳

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store