LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   rsync sending data from the client to the server? (http://www.linuxquestions.org/questions/linux-networking-3/rsync-sending-data-from-the-client-to-the-server-816941/)

mengoshmink 06-29-2010 04:05 AM

rsync sending data from the client to the server?
 
Hi all,
I hope someone can shed some light on what I am doing. I am wondering if I just have things back to front.

Server (MESH):
Fedora 13
Firewall ports open tcp 22(ssh), tcp 873(rsync)
sshd service started

Client (RADIUS):
Fedora 13
Firewall ports open tcp 22(ssh)
sshd service started

Step 1.
Create network eg hardware, network address etc

Step 2.
Test network
ping client to server
Quote:

[mengoshmink@RADIUS ~]$ ping -c 3 mesh
PING mesh.config (192.168.1.72) 56(84) bytes of data.
64 bytes from mesh.config (192.168.1.72): icmp_seq=1 ttl=64 time=0.392 ms
64 bytes from mesh.config (192.168.1.72): icmp_seq=2 ttl=64 time=0.289 ms
64 bytes from mesh.config (192.168.1.72): icmp_seq=3 ttl=64 time=0.282 ms

--- mesh.config ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.282/0.321/0.392/0.050 ms
[mengoshmink@RADIUS ~]$
ping server to client
Quote:

[mengoshmink@MESH ~]$ ping -c 3 radius
PING radius.config (192.168.1.69) 56(84) bytes of data.
64 bytes from radius.config (192.168.1.69): icmp_seq=1 ttl=64 time=0.303 ms
64 bytes from radius.config (192.168.1.69): icmp_seq=2 ttl=64 time=0.316 ms
64 bytes from radius.config (192.168.1.69): icmp_seq=3 ttl=64 time=0.292 ms

--- radius.config ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.292/0.303/0.316/0.022 ms
[mengoshmink@MESH ~]$
Step 3.
Create a folder and files on the server and client for test purposes
Client
Quote:

[mengoshmink@RADIUS ~]$ ls -l /tmp/test/
total 0
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 00:40 testRADIUS
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 09:34 testRADIUS-1
[mengoshmink@RADIUS ~]$
Server
Quote:

[mengoshmink@MESH ~]$ ls -l /tmp/test/
total 0
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 07:54 testMESH
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 07:54 testMESH-2
[mengoshmink@MESH ~]$
Step 4.
Create server-side config file
Quote:

[root@MESH mengoshmink]# nano /etc/rsyncd.conf
Code:

#motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock

[testpath]
  path = /tmp/test
  comment = Test comment
  uid = nobody
  gid = nobody
  read only = no
  list = yes
  auth users = mengoshmink
  secrets file = /etc/rsyncd.scrt

Step 5.
Create server-side secrets file and set access to it
Quote:

[root@MESH mengoshmink]# nano /etc/rsyncd.scrt
Code:

mengoshmink:secret
Quote:

[root@MESH mengoshmink]# chmod 600 /etc/rsyncd.scrt
Step 6.
Start rsync daemon on the server
Quote:

[root@MESH mengoshmink]# rsync --daemon
[root@MESH mengoshmink]#
Step 7.
View file list on the server, remotely
Quote:

[mengoshmink@RADIUS ~]$ rsync rsync://mesh/testpath/
Password:
drwxrwxr-x 4096 2010/06/29 09:17:24 .
-rw-rw-r-- 0 2010/06/29 07:54:04 testMESH
-rw-rw-r-- 0 2010/06/29 07:54:14 testMESH-2
[mengoshmink@RADIUS ~]$
Step 8.
Transfer files from the server
Quote:

[mengoshmink@RADIUS ~]$ rsync -rv rsync://mesh/testpath/ /tmp/test/
Password:
receiving incremental file list
testMESH
testMESH-2

sent 103 bytes received 203 bytes 122.40 bytes/sec
total size is 0 speedup is 0.00
Quote:

[mengoshmink@RADIUS ~]$ ls -l /tmp/test/
total 0
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 09:54 testMESH
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 09:54 testMESH-2
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 00:40 testRADIUS
-rw-rw-r--. 1 mengoshmink mengoshmink 0 Jun 29 09:34 testRADIUS-1
[mengoshmink@RADIUS ~]$
All looks good so far :)

Now for the problem
Transfer files to the server
Quote:

[mengoshmink@RADIUS ~]$ rsync -rv /tmp/test/ rsync://mesh/testpath/
Password:
sending incremental file list
testMESH
testMESH-2
testRADIUS
testRADIUS-1
rsync: mkstemp "/.testMESH.rc5Wzb" (in testpath) failed: Permission denied (13)
rsync: mkstemp "/.testMESH-2.s3IIJU" (in testpath) failed: Permission denied (13)
rsync: mkstemp "/.testRADIUS.qlYvTD" (in testpath) failed: Permission denied (13)
rsync: mkstemp "/.testRADIUS-1.qM9j3m" (in testpath) failed: Permission denied (13)

sent 229 bytes received 84 bytes 69.56 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
[mengoshmink@RADIUS ~]$
FYI
I have not written it here but I can successfully transfer files by ssh / scp.

Any comments or suggestions welcome.
Thank you in advance.

acid_kewpie 06-29-2010 04:11 AM

Right so it's failing to make a temp file in the root of the filesystem, should that user be able to do that? you can use the -T or --temp-dir option to specify a different location for temporary files.

mengoshmink 06-29-2010 04:17 AM

and our survey says ...
Quote:

[mengoshmink@RADIUS ~]$ rsync -rv -T /tmp /tmp/test/ rsync://mesh/testpath/
Password:
sending incremental file list
testMESH
testMESH-2
testRADIUS
testRADIUS-1
rsync: mkstemp "/tmp/.testMESH.rTzOBB" (in testpath) failed: No such file or directory (2)
rsync: mkstemp "/tmp/.testMESH-2.M3ONZs" (in testpath) failed: No such file or directory (2)
rsync: mkstemp "/tmp/.testRADIUS.qwhOnk" (in testpath) failed: No such file or directory (2)
rsync: mkstemp "/tmp/.testRADIUS-1.J3NPLb" (in testpath) failed: No such file or directory (2)

sent 229 bytes received 84 bytes 125.20 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]

mengoshmink 06-29-2010 06:04 PM

I think I have found the solution.
 
I think I have found the solution.

Edited /etc/rsyncd.conf
Code:

#motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock

[testpath]
  path = /tmp/test
  comment = Test comment
  uid = mengoshmink
  gid = mengoshmink

  read only = no
  list = yes
  auth users = mengoshmink
  secrets file = /etc/rsyncd.scrt

Command run on the client
Quote:

[mengoshmink@RADIUS ~]$ rsync -rv /tmp/test/ rsync://mesh/testpath/
Password:
sending incremental file list
testRADIUS-1
testRADIUSdir/
testRADIUSdir/testRADIUS

sent 171 bytes received 50 bytes 49.11 bytes/sec
total size is 0 speedup is 0.00
The critical change being the UID and/or the GID in the server-side /etc/rsyncd.conf Everything else has remained the same.

Quote:

uid
This parameter specifies the user name or user ID that file transfers to and from that module should take place as when the daemon was run as root. In combination with the "gid" parameter this determines what file permissions are available. The default is uid -2, which is normally the user "nobody".

gid
This parameter specifies the group name or group ID that file transfers to and from that module should take place as when the daemon was run as root. This complements the "uid" parameter. The default is gid -2, which is normally the group "nobody".
I have tried commenting out the two lines and I get an error, if I change just the uid or gid the file transfers successfully. However I would recommend you set the uid when the files are received they are chown-ed to that uid with read and write access whereas group and other members only have read access.

For example:
/etc/rsyncd.conf
Code:

#motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock

[testpath]
  path = /tmp/test
  comment = Test comment
  uid = mengoshmink
  gid = nobody
  read only = no
  list = yes
  auth users = mengoshmink
  secrets file = /etc/rsyncd.scrt

Files on the client:
Quote:

[mengoshmink@RADIUS ~]$ ls -lR /tmp/test/
/tmp/test/:
total 4
-rw-rw-r--. 1 root mengoshmink 0 Jun 29 09:34 testRADIUS-1
drwxrwxr-x. 2 root mengoshmink 4096 Jun 29 20:16 testRADIUSdir

/tmp/test/testRADIUSdir:
total 0
-rw-rw-r--. 1 root mengoshmink 0 Jun 29 00:40 testRADIUS
Command run on the client:
Quote:

[mengoshmink@RADIUS ~]$ rsync -rv /tmp/test/ rsync://mesh/testpath/
Password:
sending incremental file list
testRADIUS-1
testRADIUSdir/
testRADIUSdir/testRADIUS

sent 171 bytes received 50 bytes 23.26 bytes/sec
total size is 0 speedup is 0.00
[mengoshmink@RADIUS ~]$
Files received on the server:
Quote:

[mengoshmink@MESH ~]$ ls -lR /tmp/test/
/tmp/test/:
total 4
-rw-r--r--. 1 root root 0 Jun 29 22:53 testMESH
-rw-r--r--. 1 root root 0 Jun 29 22:53 testMESH-2
-rw-r--r--. 1 mengoshmink nobody 0 Jun 29 23:53 testRADIUS-1
drwxr-xr-x. 2 mengoshmink nobody 4096 Jun 29 23:53 testRADIUSdir

/tmp/test/testRADIUSdir:
total 0
-rw-r--r--. 1 mengoshmink nobody 0 Jun 29 23:53 testRADIUS
I have yet to try using different uid/gid values for different rsync 'modules' to see what happens.

I have done a quick test using the -a option (which includes -p to preserve permissions) and it has given me the same results as above but this could well be me doing something wrong.

Ultimately transmitting the files by ssh (rsync -e /usr/bin/ssh) is a much better method but I have yet to test to see what it does (if anything) to the file/folder permissions.

References:
http://www.linuxformat.com/forums/vi...ighlight=rsync

http://www.gaztronics.net/rsync.php

http://www.unix.com/shell-programmin...t-uid-gid.html

http://samba.anu.edu.au/ftp/rsync/rsyncd.conf.html

http://everythinglinux.org/rsync/

http://samba.anu.edu.au/rsync/documentation.html

lazardo 09-11-2010 04:28 PM

Did you try "rsync -rv --inplace /tmp/test/ rsync://mesh/testpath/" ?

mengoshmink 09-11-2010 04:33 PM

No, --inplace is not a switch that I had tried. What does it do?

romagnolo 07-20-2012 09:17 PM

Quote:

Originally Posted by mengoshmink (Post 4018771)
I think I have found the solution.

I confirm that is a solution and it worked on my debian which as yours runs rsync daemon as root.

mengoshmink 07-21-2012 04:33 PM

Pleased to hear it. I must implement this solution to my new clients and file server.


All times are GMT -5. The time now is 05:04 AM.