howto enable ssh on connect to rsync daemon

wilma wilma2002 at spray.se
Fri Oct 10 01:55:24 EST 2003


Hello list,
thanks for your input.
As Hans Eric pointed out earlier this is what I had to do:

1. create a private key on node1, with no  passphrase and rename the file to just use with rsync:
ssh-keygen -t rsa
cd /.ssh
mv id_rsa id_rsa_rsync

2. copy the contents of /.ssh/id_rsa.pub to node1:
scp .ssh/id_rsa.pub node2:.ssh/authorized_keys

3. use the following command from node1 to make the sync from node2

rsync -avz --delete --rsh=”ssh –i /.ssh/id_rsa_rsync” 
root at node2:/path/to/resource/ /path/to/localresource/

Thanks
-wilma-
 

------ Ursprungligt meddelande ------------------- 
Från: Hardy Merrill <hmerrill at redhat.com> 
Datum: Thu, 9 Oct 2003 10:13:31 -0400 
Ämne: Re: howto enable ssh on connect to rsync daemon 

Wilma, the manpage section titled

   CONNECTING TO AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM

says this

       It  is sometimes useful to be able to set up file transfers using rsync
       server capabilities on the remote machine, while still using rsh or ssh
       for transport.  This is especially useful when you want to connect to a
       remote machine via ssh (for encryption or to get through  a  firewall),
       but  you  still  want  to have access to the rsync server features (see
       RUNNING AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM, below).

       From the user's perspective, using rsync in this way  is  the  same  as
       using it to connect to an rsync server, except that you must explicitly
       set the remote shell program on the command  line  with  --rsh=COMMAND.
       (Setting RSYNC_RSH in the environment will not turn on this functional-
       ity.)

       In order to distinguish between the remote-shell  user  and  the  rsync
       server user, you can use '-l user' on your remote-shell command:

              rsync -av --rsh="ssh -l ssh-user" rsync-user at host::module[/path]
              local-path

       The "ssh-user" will be used at the ssh level; the "rsync-user" will  be
       used to check against the rsyncd.conf on the remote host.

After reading that and looking at your command in the script
   rsync -av --delete node2::resource /path/to/localresource > $LOG 2>&1

I don't think you can just set environment variable USER and
have that work right.  Try specifying the command as the manpage
suggests, with the --rsh="ssh -l ssh_user" rsync-user at host::module

HTH.
-- 
Hardy Merrill
Red Hat, Inc.

 wilma  [wilma2002 at spray.se] wrote:
> Hi,
> I'm trying to setup automatic sync of files over SSH from node2 to node1.
> node2 is the "server" and node1 is the "client".
> I have setup rsync like this on the nodes which runs AIX (4.3.3 and 5.1):
> 
> 1. Installed rsync from Linux Toolbox (rsync-2.5.4-1.aix4.3.ppc.rpm) on both nodes.
> 2. Added following to both nodes /etc/services file:
>      rsync           873/tcp
> 3. Added following to node2 /etc/inetd.conf and refreshed inetd
>      rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon
> 4. Created /etc/rsyncd.conf on node2 with this content:
>      log file = /var/log/rsyncd.log
> 
>      [resource]
>              path = /path/to/resource
>              comment = resource file area
>              read only = yes
>              auth users = user
>              hosts allow = node1
>              secrets file = /etc/rsyncd.secrets
> 5. Created /etc/rsyncd.secrets at mode 600 on node2 with this content:
> user:password
> 6. Created a script on node1 to be used from cron with this content:
>      #!/bin/ksh
>      #
>      LOG=/var/log/rsync.log
>      export USER=user
>      export RSYNC_RSH=ssh
>      export RSYNC_PASSWORD=password
> 
>      echo $(date) >> $LOG
>      echo "" >> $LOG
> 
>      rsync -av --delete node2::resource /path/to/localresource > $LOG 2>&1
>      echo "**********************************************" >> $LOG
> 
> --------------------------------------------------------------------------------------------------------
> The script runs fine, but I can see in an iptrace it does'nt use SSH. Instead it connects to port 873 on
> node2.
> I have tried adding the flag --rsh "ssh" to the command but it tells me this:
> "WARNING: --rsh or -e option ignored when connecting to rsync daemon"
> 
> Can someone please help how to set this up to go over SSH and without the need to supply a password?
> Thanks in advance
> -wilma-
> 
> ____________________________________________________________
>   Singelkryssen lättar ankar igen! Ta med kompisarna!
>   http://www.spray.se/datekryss

____________________________________________________________
  För alla singlar - singelkryssen lättar ankar igen den 23 oktober. Boka nu!
  http://www.spray.se/datekryss



More information about the rsync mailing list