Monday, April 5, 2021

Copy files from/to remote server using PuTTY pscp

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.


1.Download PSCP.EXE from Putty download (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) page

2.set New Path in environment variable  = C:\Program Files\PuTTY\pscp.exe

3.now open command prompt type pscp if pscp is successfully installed it will show its version.


Okey pscp now successfully setup.



Transferring file from server to localhost

Now we have to zip the directory which we want to copy because without zip we cant copy directory.


1. First zip a directory using putty 

   Goto the directory folder the make a zip file of that directory by following command = zip -r directoryName *

   From test server: zip -r ready_products * 

   It will make zip file of ready_products

   

   if you need unzip that folder enter unzip latest.zip

   

   if you need to delete the zip folder the enter unlink folder.zip or rm folder.zip

   

2.use the following command to copy file form remote server to the local system

So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type

e.g: pscp -P 22 fred@example.com:/etc/hosts c:\temp\example-hosts.txt

   

    From test server : pscp -P 22 kldev@example.com:/var/www/project/storage/app/public/images/ready_products.zip C:\wamp64\www


Now Transferring file from localhost to remote server


1. pscp -P 22 filename_from_localhost kldev@server_ip_address:/server_folder_location


e.g.1 pscp -P 22 Library_Management.zip kldev@93.100.111.222:/var/www/Library_Management_Project/public_html/


e.g.2 pscp -P 22 ready_products.zip kldev@example.com:/var/www/project/storage/app/public/images/


Link 1 : https://stackoverflow.com/questions/6217055/how-can-i-copy-a-file-from-a-remote-server-to-using-putty-in-windows

Link 2: https://akshay-waingankar95.medium.com/copy-files-from-to-remote-server-using-putty-pscp-7567a0631c9d

Link3: https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter5.html