Welcome to WebmasterWorld Guest from 54.226.133.245

Forum Moderators: bakedjake

Message Too Old, No Replies

File Transfer between two remote servers

     
7:25 am on Apr 26, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:July 2, 2003
posts: 112
votes: 0


I have two dedicated linux servers with SSH/SFTP/root access and I want to transfer files from one server to another remotely. How can I do that?

Please suggest
7:29 am on Apr 26, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


I guess you need CURL or similar.
7:39 am on Apr 26, 2011 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


What about logging on to the first server with SSH and starting an SFTP session to the second?
7:44 am on Apr 26, 2011 (gmt 0)

Junior Member

10+ Year Member

joined:July 2, 2003
posts: 112
votes: 0


@lammert
I am very new to linux commands or SSH. can you please elaborate a bit :(
8:00 am on Apr 26, 2011 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


SSH is a protocol which allows to to login to a text command prompt on one of the remote servers. This allows you to start commands directly on that server. If your desktop is not Linux based, you will need a terminal emulation prgram to create that connection.

On the remote server you can use the SFTP command to transfer files from one server to the other. SFTP is a command line tool which allows you send files from one of the servers to another.
7:38 am on May 30, 2011 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14622
votes: 86


SFTP is just like FTP if you've ever used it, just secure
2:43 pm on May 30, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


If you are using SSH you can scp files as well


scp local/file/path/here username@server_name_or_ip:/location/to/copy/to

If I want to copy a file to example.com

scp /home/test/thefile.xml test@example.com:/tmp/


If I want to copy a file from example.com

scp test@example.com:/tmp/thefile.xml /home/test/
3:19 pm on May 30, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 11, 2003
posts:5063
votes: 11


Per Demaestro.

I use 'scp' (secure copy) to copy files. Just like copy, but encrypted and between two servers. It's the only thing I use, never use FTP because I don't run ftp on my machines.

You may also want to add the -C switch, which compresses the file. That can speed things up a bit. i.e. copy file1 from server1 to server2, on server1:
scp -C /home/user/file1 root@server2.com:/home/user

You must have ssh running on server2 to make this work though.

If you want to automate the copying, say through a cron job running on server1 (so it copies files every night) you may want to use rsync instead of scp. rsync is like scp, but adds the capability of only copying over changed files, thus reducing bandwidth. I use rsync to automate copying my webserver backups to an offsite machine. Full details here:
[webmasterworld.com...]

The important part in that post is setting up the public keys so that server1 can log into server2 without getting prompted for a userid/password. However the same thing works for scp as well - if you set up the keys as noted in that post, then server1 can scp or ssh (or rsync) to server2 without a password request.