LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Rsync copies my SSH key over when I don't want it to (http://www.linuxquestions.org/questions/programming-9/rsync-copies-my-ssh-key-over-when-i-dont-want-it-to-742909/)

Raze 07-26-2009 10:14 AM

Rsync copies my SSH key over when I don't want it to
 
I'm trying to use rsync to backup a directory from one machine to another, via SSH and a key. But it copies my private key over too - when I don't want it to.

I've tried '--exclude=keyname' but that just stops it from working altogether.

Here's my code:

Code:

rsync -ave "ssh -i /path/to/sshkey" /path/to/original/files/on/my/machine dest@ip.add.ress:/path/to/backup/directory/on/destination/machine/
Any ideas on how to get it not to copy my private ssh key over?
Also, is this the correct code to get it to keep these two folders in sync? (basically a mirror of the folder on machine1 to the folder on the destination machine2).

Thanks in advance!

jschiwal 07-26-2009 10:35 AM

The --exclude option works for me.
I use pubkey authentication, and have the same credentials and uid on the target machine.
I just ran your command and transferred a directory from my laptop to my desktop:
rsync -ave "ssh" --exclude list1 work/ jschiwal@hpmedia:rsynctest/

Could you give the entire line you used with the --exclude option. I used the source directory ~/work as the base for the excluded files pathname. You concealed too much info to see if this was your problem.

Raze 07-26-2009 01:27 PM

Hi, thanks for the reply.

The line with exclude was:

Code:

rsync --exclude=sshkey -ave "ssh -i /path/to/sshkey" /path/to/original/files/on/my/machine dest@ip.add.ress:/path/to/backup/directory/on/destination/machine/
I am trying to do this on two web servers.

The first bit of code I used works, but it copies the ssh key over too, but when I exclude the key I get this:

Quote:

sent 17 bytes received 21 bytes 25.33 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files could not be transferred (code 23) at main.c(1298) [receiver=2.6.8]
The actual code looks more like this:

rsync -ave "ssh -i /home/accname1/.ssh/sshkey" /home/accname1/public_html/rsynctest accname2@35.53.139.70:/home/accname2/public_html/rsynctest/

jschiwal 07-27-2009 12:40 AM

The .ssh/id_rsa (or .ssh/sshkey) isn't among the files being synced.
from: /home/accname1/public_html/rsynctest
to: /home/accname2/public_html/rsynctest/


This test worked for me as well:
rsync -ave "ssh" --exclude="list?" work/ jschiwal@hpmedia:rsynctest/

It excluded the files work/list1, work/list2 and work/list3.

Then I copied the list1, list2, list3 and listing files to work/test/ and ran rsync again. Only the "listing" file was replicated.


All times are GMT -5. The time now is 01:34 AM.