Server to Server transfer using ssh

  • atulb
  • Born
  • Born
  • atulb
  • Posts: 1

Post 3+ Months Ago

i am moving my exiting website to another server, and i have shell access to both servers. How can transfer files from existing server to the new servers.

thanks in advance
  • GQuest
  • Born
  • Born
  • User avatar
  • Posts: 3

Post 3+ Months Ago

- tar your files
- put them in a webdirectory
- lynx em from the other server
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

What I usually do is somewhat exactly what GQuest said. I would definetely tar them up because your file permissions should be preserved making it less work for your to prepare you site on the new server. First I would login through ssh or telnet to the server with the website. Here are the commands I would type:

cd /home/somepath/to/yourwebsite/public_html
tar -cvf sitepack.tar ./

Once that is finished I would goto your new server and login through telnet and ssh. Here I would type:

cd /home/somepath/to/yourwebsite/public_html
wget yourdomain.com/sitepack.tar
tar -xvf sitepack.tar

At this point I would check to make sure the correct owner and group are on your files you just unpacked. You can check to see what they are by typing:

ls -la

If the owner or group is wrong you can type this to fix all the files:

chown -R owner.group ./

owner.group should be replaced with the owner name you want and the group name you want. This will recursively go through all your files and directories and changed them to the correct owner and group.
  • zynch
  • Born
  • Born
  • zynch
  • Posts: 1
  • Loc: philippines

Post 3+ Months Ago

I just successfully used that but accidentally the tar file was renamed to public_html instead of tar.tar lol, can you help me on how to rename this file to tar.tar ? thanks in advance :roll:
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

If you are sure public_html is not a directory and actually a file, you can rename that by typing this in ssh:

mv public_html tar.tar

That will rename public_html to tar.tar
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Since you already suggested using SSH, then rsync may be for you. This utility is awesome as providing a secure method to transfer files in bulk and is the tool for keeping two sets of files in sync.

As a bonus, you can run it as a background task on the server. That means you won't have to configure inetd or xinetd. Assuming you have working SSH on the client and server:

(server)
tar -zxvf rsync
cd rsync
./configure
make
install
/usr/bin/rsync --daemon $

(client)
tar -zxvf rsync
cd rsync
./configure
make
install
rsync -rvz server:/dir/dir/dir /backup/dir

The best part of rsync is that if some files change in the server /dir/dir/dir directory, the next transfer will only be the updates. This equals speed improvements a few hundred times faster!

I'm not sure about server to server transfers (maybe fsp). Maybe daemonguy has a suggestion...
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

Good lord! wget?

If they have ssh enabled, than I am comfortable saying that scp is functioning. SCP is secure copy that transfers files much like ftp though over SSH tunneling.

tar up the files as mentioned -- preserve integrity of course (attime preserve and preserve permissions).

Either go from original host to new host or vice versa.

scp localfile myname@<newhost>:/<path to owned directory>
or
go to the new host and do it the other way.
scp username@<oldhost>:<path to file> ./

Cheers.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Secure Copy Man Page

OpenBSD Reference Manual SCP(1) wrote:
Any file name may contain a host and user specification to indicate that the file is to be copied to/from that host. Copies between two remote hosts are permitted.

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

-r Recursively copy entire directories.


Abbreviated Usage wrote:
scp -rp [[user@]host1:]file1 [...] [[user@]host2:]file2


You could go from host to host (by passing your computer), recuse subdirectories and preserve modification times, access times, and modes from the original file with this command:

scp -rp username@host1:/www/ username@host2.com:/www

Ownership of files was not identified as preserved according to the scp man page. This is be a problem if file ownership should not be your username:groupname on the new host. You should test -p and verify (please post your result here if you do).

You can either:
a) Use chown to change all these files (it can recurse subdirectories), or
b) tar the files and extract them on the destination server.

Since scp does not compress on-the-fly, you will be preserving bandwidth by using a compression (i.e. files.tar.gz).

Daemonguy wrote:
Good lord! wget?


There more than one way to do things. scp is a great utility and I'm glad to have learned about it (thats the great thing about discussion forums).

Every tool has its strength and weakness. For example, scp can preserve file properties and rsync can compress on-the-fly. Other utilities are beneficial because of familiarity: ftp and wget, for example.

Your suggestions on this discussion forum are always very helpful and I look forward to your perspective. However, it shouldn't come at the price of discouraging others from offering their help.
  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

rjmthezonenet wrote:


Daemonguy wrote:
Good lord! wget?


There more than one way to do things. scp is a great utility and I'm glad to have learned about it (thats the great thing about discussion forums).

Every tool has its strength and weakness. For example, scp can preserve file properties and rsync can compress on-the-fly. Other utilities are beneficial because of familiarity: ftp and wget, for example.

Your suggestions on this discussion forum are always very helpful and I look forward to your perspective. However, it shouldn't come at the price of discouraging others from offering their help.


Pardon my surprise; for that is the sole reason for my response, such as it was. I also did not realize I was being "discouraging" -- I thought I was being helpful, go figure.
I doubt rsync would be useful, unless he could set one machine up as the rsync daemon server, and even then it's more useful for diff's -- and quite a bit more work for a single instance transfer of data.
In any case, I shall endeavor to curb my responses henceforth.

Cheers.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

I found his in the help documentation for CuteFTP

Quote:
CuteFTP is capable of transferring files from one remote server to another. Some servers do not allow this style of transfer; if you’re having difficulty getting this feature to function properly, please contact the administrator of the FTP site to see if Site-to-Site Transfers are supported.

To perform a Site-to-Site transfer:

1. Connect to the first remote site and choose Window > New CuteFTP Window to launch another instance of CuteFTP.
2. Connect to the second site in the new window.
3. Drag and drop the desired file from one window to the other.


Few FTP clients support site-to-site tranfers (FXP) and both servers must allow it. gFTP is another client that I know of that does support this.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

FlashFXP also does this.. I've been using FlashFXP for years and it's great, but like the quote, not all servers allow FXP transfers, and I believe the ability is disabled by most Linux distros by default - allowing FXP can potentially open up one or two DoS problems.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Axe wrote:
...he ability is disabled by most Linux distros by default...


Apparently ipchains dropped support. Sorry, I can't remember specifics.
  • phpSelectah
  • Student
  • Student
  • User avatar
  • Posts: 97

Post 3+ Months Ago

scp, ffs. :D

unless your are going to do this on a daily basis, or some other high frequency, then I would recommend rsync.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

rjmthezonenet wrote:
Apparently ipchains dropped support. Sorry, I can't remember specifics.


As well as that, there's a setting in most FTPd configs that has to be changed to allow it - even if IPChains isn't blocking anything...

I do remember when I was setting up wuftpd for shifting files across my LAN from one box to several others, I had to modify the configs to allow FXP support. I just told it what to shift where from my windows machine with FlashFXP.
  • fehers
  • Born
  • Born
  • fehers
  • Posts: 1
  • Loc: Serbia and Montenegro

Post 3+ Months Ago

Hello,

I read all the posts on this page and since I haven't found the answer to my question I post it here. What interests me is how can I transfer the file http://us2.php.net/distributions/php-5.0.2.tar.bz2 to a ftp server.

I know how can I transfer it using wget on a same server wget is installed on and I know how can a file be copyed and/or moved from one ftp server to other ftp server. For information purposes I do this using Net2Ftp. A cool server sided php script that can do all the move-copy stuff but not form an "ordinary" url address as above. Anybody know how can I do it using ssh or some other software? To simplify it... Remote transfer a file from one server to another...
  • summerbreeze
  • Born
  • Born
  • summerbreeze
  • Posts: 1

Post 3+ Months Ago

fehers wrote:
Hello,

I read all the posts on this page and since I haven't found the answer to my question I post it here. What interests me is how can I transfer the file http://us2.php.net/distributions/php-5.0.2.tar.bz2 to a ftp server.

I know how can I transfer it using wget on a same server wget is installed on and I know how can a file be copyed and/or moved from one ftp server to other ftp server. For information purposes I do this using Net2Ftp. A cool server sided php script that can do all the move-copy stuff but not form an "ordinary" url address as above. Anybody know how can I do it using ssh or some other software? To simplify it... Remote transfer a file from one server to another...


yep, it's called a remote upload via http to your ftp server. try this application http://directransfer.net it worked for me.
  • sava
  • Newbie
  • Newbie
  • sava
  • Posts: 12

Post 3+ Months Ago

Hello,

Is it possible to transfer a large backup? About 5Gb?
Thanks
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Yes. Like daemonguy said a couple of years ago, use scp.
  • sava
  • Newbie
  • Newbie
  • sava
  • Posts: 12

Post 3+ Months Ago

Hello kc0tma,

I used: "scp file-name.tar.gz -p 2222 user@xxx.xxx.xxx.xxx:/path/to/save"
Where my new server use port 2222.

But I got "ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out".

How to specify the port number? What's wrong with my command?
Thanks
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

scp manpage wrote:
-P port
Specifies the port to connect to on the remote host. Note that
this option is written with a capital ‘P’, because -p is already
reserved for preserving the times and modes of the file in
rcp(1).


In your command you used a lowercase p, did you actually use that on the server?
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Also, does scp work if you do not use -P 2222? What happens if you let it use the default port?
  • sava
  • Newbie
  • Newbie
  • sava
  • Posts: 12

Post 3+ Months Ago

Yes it's works but i get this message:
"ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out"
  • sava
  • Newbie
  • Newbie
  • sava
  • Posts: 12

Post 3+ Months Ago

Forgot to sat that I tested with lower and uppercase, no different!

I get the same message:

ssh: connect to host xxx.xxx.xxx.xxx port 22: Connection timed out
lost connection
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

So I'm guessing that the remote machine isn't configured to accept ssh connections on port 22 based on "Connection timed out".

Does scp work if you type only "scp file-name.tar.gz user@xxx.xxx.xxx.xxx:/path/to/save"

edit: I just looked up what port 22 is normally used for, and it is actually ssh. Since 22 is the default ssh port, you shouldn't need the -P option. In your earlier post you said you were trying to use port 2222, why are you trying to use that?
  • sava
  • Newbie
  • Newbie
  • sava
  • Posts: 12

Post 3+ Months Ago

Hi kc0tma,
Thanks for your reply and trying helping me.
My hosting has blocked port 22, I have to use port 2222 when I use ssh or sftp. It's therefore.
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Does your host allow 2222? Or do they want you to use some other port instead?
  • jitendraag
  • Newbie
  • Newbie
  • jitendraag
  • Posts: 8

Post 3+ Months Ago

tar -cvzf or -cvjf on one server and -xvzf on another and you are done.

You can ftp the bz2 file and then bzip2 -d or bunzip on your server.
  • Deem3n
  • Born
  • Born
  • Deem3n
  • Posts: 4

Post 3+ Months Ago

As alternative try rsync over ssh:
Code: [ Select ]
rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/

Post Information

  • Total Posts in this topic: 28 posts
  • Users browsing this forum: No registered users and 3 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.