Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete remote file with key based auth #369

Closed
rmazzotta opened this issue Apr 12, 2016 · 7 comments
Closed

Delete remote file with key based auth #369

rmazzotta opened this issue Apr 12, 2016 · 7 comments

Comments

@rmazzotta
Copy link

I can not for the life of me get lsync to delete files remotely. I am using a no-pass key for auth. copying new and updating changed works just fine. Deleting however is not working. If I restart lsyncd the file actually deletes. But when it tries to delete a file during the normal operation I get the following:

Tue Apr 12 20:23:08 2016 Normal: Finished (list): 0
Tue Apr 12 20:23:40 2016 Normal: Deleting list
/etc/dir//123
Permission denied (publickey).

My plain rsync command is:
rsync -rvzl -e "ssh" --rsync-path="sudo rsync" /etc/dir/ 10.2.1.20:/etc/dir/

My lsync conf is:
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
default.rsyncssh,
source = "/etc/dir/",
host = "10.2.1.20",
targetdir = "/etc/dir/",
delete = true,
rsync = {
links = true,
verbose = true,
rsh = "/usr/bin/ssh -l admin -i /home/admin/.ssh/id_rsa",
rsync_path = "sudo rsync"
}
}

@axkibe
Copy link
Collaborator

axkibe commented Apr 12, 2016

If you change the user and id file with rsh, you have to do the same thing with the ssh connection.

I advise using simple "default.rsync" config and leave the ssh fluff away.

@axkibe axkibe closed this as completed Apr 12, 2016
@rmazzotta
Copy link
Author

I am confused. I though default.rsync is for local sync not remote? I am trying to copy to another server.

@axkibe
Copy link
Collaborator

axkibe commented Apr 12, 2016

default.direct is for local.

@rmazzotta
Copy link
Author

Does nto work at all. Permission denied.

sync {
default.rsync,
source = "/etc/dir/",
target = "10.2.1.20:/etc/dir/",
delete = true,
}

@rmazzotta
Copy link
Author

got it!! thank you for your help!!

sync {
default.rsync,
source = "/etc/dir/",
target = "admin@10.2.1.20:/etc/dir/",
delete = true,
rsync = {
links = true,
verbose = true,
rsh = "/usr/bin/ssh -l admin -i /home/admin/.ssh/id_rsa",
rsync_path = "sudo rsync"
}
}

@RaimundasR
Copy link

got it!! thank you for your help!!

sync {
default.rsync,
source = "/etc/dir/",
target = "admin@10.2.1.20:/etc/dir/",
delete = true,
rsync = {
links = true,
verbose = true,
rsh = "/usr/bin/ssh -l admin -i /home/admin/.ssh/id_rsa",
rsync_path = "sudo rsync"
}
}

Just would like to inform that this issue I have only on ubuntu 18, so from Ubuntu 20.04 everything works fine with "rsh".

But this one was a great solution form me, thank you :)

@ychaouche
Copy link

Came here to give a thanks too,
I was struggling with lsyncd 2.1.5 that didn't want to hear about my ssh identity key no matter what.
I've been pulling my hair on this.
Thanks again.

btw, I didn't have to use rsync_path
since I use lsyncd as root via sudo anyway,
same for specifying the user in the target variable or the -l switch.
Here's my conf

settings {
   logfile        = "/var/log/lsyncd.log",
   statusFile     = "/var/log/lsyncd.status",
   insist         = true,
   nodeamon       = true,
   verbose        = true
}

sync {
  default.rsync,  
  source        = "/home/ychaouche/SYNCHRO",
  target        = "10.10.10.82:/root/SYNCHRO",
  rsync = {
     copy_links = true,
     rsh = "/usr/bin/ssh -i /root/.ssh/idroot",      
  }  
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants