October 14, 2019

How to transfer files/folder from one Linux server to another

Suppose you want to backup or transfer files from one remote server to another you can do it simply by using scp. Let me brief you about SCP.

SCP stands for secure copy (remote file copy program).

scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords or passphrases if they are needed for authentication.

COPY CODE SNIPPET

File names may contain a user and host specification to indicate that the file is to be copied to/from that host. Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers. Copies between two remote hosts are also permitted.

Enough of theory stuff, let’s see the example:

Suppose you want to transfer files/folder from 12.34.56.789 to 88.12.98.980. Therefore first login to the server 88.12.98.980 and run the following command as follows:-

scp -r [email protected]:/var/www/html.zip /var/www/html/

where

-r = Recursively copy entire directories. Note that scp follows sym‐bolic links encountered in the tree traversal.

root = User of that machine.

12.34.56.789 = Ip of the server where the data exists.

/var/www/html.zip = File that resides on 12.34.56.789 server.(from where u will transfer)

/var/www/html = Directory of 88.12.98.980 server where the files will be copied.

For the server which doesn’t have the default port 22 run the following command:

scp -r -P1234 [email protected]:/var/www/html.zip /var/www/html/

Done Enjoy!!😎

Vedant Singh

Linux System Administrator | Entrepreneur | Founder Techmion. I have started my career as a Linux system Administrator after that quit my job to start something new that excites me and started a Tech Company in order to provide the best technology to my clients. My Company website link: Technology at its best For Bulk, SMS-Marketing follows the link : https://www.pingsms.in/

View all posts by Vedant Singh →

Leave a Reply

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