Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my target is to copy /tmp/my_file from 10.10.10.1 to my Linux machine without login and password , I set the passwords file with the right password - secret123 so rsync should work , please advice why I get Permission denied.

Remark - 10.10.10.1 address is linux machine version – red hat 5.3

   rsync -WavH --password-file=/tmp/passwords --progress root@10.10.10.1:/tmp/my_file .


   Permission denied.
   rsync: connection unexpectedly closed (0 bytes read so far)
   rsync error: error in rsync protocol data stream (code 12) at io.c(165)

   more /tmp/passwords
   secret123

   ls -ltr  passwords
   -rwxr-xr-x    1 root     root           10 Sep 12 17:32 passwords
share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

It looks like you may be using SSH to connect to root. SSH usually doesn't allow logins to root, and many distributions don't allow root logins at all. You might be better off using an SSH authorized key to enable you to connect as root.

It would be better to connect to an account other than root if you can.

If you want to use an rsync deamon on the remote end I believe you need two colons after the server specification. Rsync user ids are not the same as system user ids. Access is controled by the rsync configuration file.

EDIT: If you are using an rsyncd deamon on 10.10.10.1 then either of these should work. (NOTE: I changed the user id, try to avoid using root.) I also assume you have a tmp module mapping to /tmp.

rsync -WavH --password-file=/tmp/passwords --progress rsync@10.10.10.1::tmp/my_file .
rsync -WavH --password-file=/tmp/passwords --progress rsyncd://rsync@10.10.10.1:tmp/my_file .

Verify you can connect to the daemon process with the command telnet 10.10.10.1 873 which should return an RSYNC version. You can also test using rsync with the command rsync 10.10.10.1:: which should return a list of public shares. Add your userid and password file to the command to get private shared.

If, as it appear,s you are using ssh, use a private key. You can use ssh-agent and ssh-add to load the key so you don't need to enter the password. Again don't use root unless you must. It would be better to give access to the file using a different group, and setup a userid with access to that group.

You can test ssh access with ssh. If the file is always new when you want to copy it, then scp would be simpler than rsync.

Try testing access without a copy option. Something like this should work:

rsync -vvv --password-file=/tmp/passwords rsync@10.10.10.1::tmp/my_file

EDIT2: I re-read your query. It appears you want to copy a single file without login. The easiest approach would be to use scp with am authorized key file on the remote system. Few files are only readable by root, so you should be able to use a different user id. Try a command like:

scp user@10.10.10.1:/tmp/my_file . 

The only advantage to using rsync is to avoid copying the file if it hasn't been replaced. Because you use the -W option, you loose the advantage of only transferring changes. For log files the --append option can be helpful in speeding up transfers.

share|improve this answer
    
about "two colons after the server specification." please give me example of the right syntax (what I need to fix in my syntax?) –  Diana Nov 13 '11 at 16:02
add comment

--password-file option can be used only when connecting to a rsync server.

You have to use rsync over ssh with key authentication in order to work.

-password-file This option allows you to provide a password in a file for accessing an rsync daemon.

from: rsync man page

share|improve this answer
add comment

The simplest way would be to setup SSH keys and use these to establish your rsync connection.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.