LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2009, 10:14 AM   #1
Raze
LQ Newbie
 
Registered: Apr 2007
Posts: 3

Rep: Reputation: 0
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!
 
Old 07-26-2009, 10:35 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 07-26-2009 at 10:38 AM.
 
Old 07-26-2009, 01:27 PM   #3
Raze
LQ Newbie
 
Registered: Apr 2007
Posts: 3

Original Poster
Rep: Reputation: 0
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/
 
Old 07-27-2009, 12:40 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
  


Reply

Tags
rsync



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
open-ssh vs. commercial ssh (tru64), public-key auth not possible? cf050 Linux - Networking 8 03-28-2012 11:15 AM
Rsync server vs rsync over ssh humbletech99 Linux - Networking 1 10-18-2006 12:10 PM
using rsync with cron & pub. key kmitz Fedora 0 01-14-2005 08:01 AM
How do i backup a dns server? I am using rsync but the key dont match abefroman Linux - Networking 2 03-11-2004 08:16 AM
How do i backup a dns server? I am using rsync but the key dont match abefroman Linux - Newbie 1 03-09-2004 07:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration