| Subcribe via RSS

scp server to server

February 6th, 2008 | 6 Comments | Posted in server by dreamluverz

SOURCE: http://forums.serverbeach.com/archive/index.php/t-2202.html

I’ve been looking for this reference and finally found it. Thanks for them who posted it on the link above. :) I’ll be trying this out :)



Let’s begin and assume the following information:
Server A is our host where the original files are located.
Server B is where we need to copy files to.

1. Make sure on Server A you have enabled Shell access for the user account you are going to use. Let’s say our files are in /home/user1/public_html/myfiles. In this case, make sure you enable user1 shell access.

2. Login SSH on Server B, login as root “su”, or as user1 should work too so long as you stick the files in the same place.

3. Type this command:
where xx.xx.xx.xx is the IP address of Server A

scp -rv user1@xx.xx.xx.xx:/home/user1/public_html/myfiles/ /home/user1/public_html/myfiles/

notice there is a *SPACE* after /myfile/ and /home/

You will be prompted for the SSH password of user1 at Server A. Enter this, and the copy process will start.

the -r option copies everything in the directory tree.
/home/user1/public_html/myfiles/dir1/
/home/user1/public_html/myfiles/dir2/
/home/user1/public_html/myfiles/dir3/moredir1/
etc…..

the -v option is verbose, lets you see the transfer in action in your ssh terminal.

==========================

scp with -p options is better
scp -prv user1@xx.xx.xx.xx:/home/user1/public_html/myfiles/ /home/user1/public_html/myfiles/

the -p option Preserves modification times, access times, and modes from the original file

Tags: , ,