How to copy from server to server. (Linux to Linux)

How to copy from server to server. (Linux to Linux)


For example we have two server, with two different IP address. both of this sever runs on linux. freebsd to ubuntu, ubuntu to freebsd. any to any.

First way is to use scp.

Source server name : sourceserver1
Destination server name :  destinationserver1
Location and File name : /home/sourceuser/file.txt

we can do this command in source server, or in the destination server. this depends on the access you have on the server and the availability of resources. which one come best depends on the situation.

From Source server.

Login into your source server.


syntax : scp <source> <destination>
scp /home/sourceuser/file.txt destuser@destinationserver1:
Command above will copy file.txt from the source server to the /home/destuser/


In Destination server. Reverse Copy

Login into your destination server.

syntax : scp <source> <destination>
cmd : scp sourceuser@sourceserver1:file.txt ./
Command above will copy file.txt from the source server into your current folder u reside in. In the comand (./) means current directory.

How to SCP from amazon AWS.

U will need the .pem key. and the amazon Public DNS.


From your AWS server. (In source, to destination)

cmd : scp -i awsuser.pem file.txt root@amazonPublicDNS:
Comand above will put your file in the home directory of root.

In your destination AWS server (Reverse copy)

cmd : scp -i awsuser.pem root@amazonPublicDNS:/path/to/file.txt ./

If u have any problem or quetion, please add comment below.

Comments