简体   繁体   English

删除文件时,lsyncd不尊重ssh用户

[英]lsyncd doesn't respect ssh user when deleting files

We have setup lsyncd to sync data between two hosts. 我们已设置lsyncd以在两台主机之间同步数据。 The ssh connection is configured to use user tomcat with the matching id_rsa identity file. ssh连接配置为使用具有匹配的id_rsa标识文件的用户tomcat。 For some reason a append/create on the remote works fine, but deleting doesn't work. 由于某种原因,遥控器上的追加/创建工作正常,但删除不起作用。 When rsync tries to delete a file, the root user is used to connect to the destination host and not the tomcat user (which is used for create/append). 当rsync尝试删除文件时,root用户用于连接目标主机而不是tomcat用户(用于create / append)。

In the logs ( /var/log/lsyncd/lsyncd.log ) we see: 在日志( /var/log/lsyncd/lsyncd.log )中,我们看到:

Wed Feb 15 13:48:24 2017 Normal: Rsyncing list
/test.txt
Wed Feb 15 13:48:26 2017 Normal: Finished (list): 0
Wed Feb 15 13:48:34 2017 Normal: Deleting list
/myfolder//test.txt
Received disconnect from 10.29.146.78: 2: Too many authentication failures for root
Wed Feb 15 13:48:41 2017 Normal: Retrying (list): 255

We use the below configuration ( /etc/lsyncd.conf ): 我们使用以下配置( /etc/lsyncd.conf ):

settings{
  pidfile        = "/var/run/lsyncd.pid",
  statusFile     = "/var/tmp/lsyncd.status",
  logfile        = "/var/log/lsyncd/lsyncd.log",
  statusInterval = 60,
  logfacility    = "user",
  logident       = "lsyncd",
  inotifyMode    = "CloseWrite",
  maxProcesses   = 10,
}

sync {
  default.rsyncssh,
  source = "/myfolder/",
  delete = true,
  host = "remote-host",
  targetdir = "/myfolder/",
  excludeFrom = "/etc/lsyncd/lsyncd.exclude",
  delay = 5,
  rsync = {
    binary = "/usr/bin/rsync",
    archive = true,
    owner = true,
    compress = true,
    _extra = { "--bwlimit=50000", "--delete-after" },
    rsh = "/usr/bin/ssh -l tomcat -i /usr/share/tomcat6/.ssh/id_rsa",
  }
}

As a workaround we can use a /root/.ssh/config file with: 作为一种解决方法,我们可以使用/root/.ssh/config文件:

Host remote-host
    Hostname remote-host
    User tomcat
    IdentityFile /usr/share/tomcat6/.ssh/id_rsa

Of course we would rather not have to use this since it should work with the lsyncd.conf configuration. 当然,我们宁愿不必使用它,因为它应该与lsyncd.conf配置一起使用。

We're using lsyncd version 2.1.4 我们使用的是lsyncd 2.1.4版

When using rsyncssh, one has to be careful. 使用rsyncssh时,必须要小心。

The "ssh {}" configuration parameter has its own "binary", "port", "_extra". “ssh {}”配置参数有自己的“二进制”,“端口”,“_ extra”。 See documentation for complete list of settings. 有关完整的设置列表,请参阅文档

It is a little confusing because "rsync {}" also needs to be configured. 这有点令人困惑,因为还需要配置“rsync {}”。 Yes, both sections need to be done. 是的,这两个部分都需要完成。

The "ssh" section is used for delete and move events. “ssh”部分用于删除和移动事件。 The "rsync" section is used for file transfer. “rsync”部分用于文件传输。

One might avoid the confusion by using rsync instead of rsyncssh. 人们可以通过使用rsync而不是rsyncssh来避免混淆。 But, you would lose the bandwidth efficiency that rsyncssh provides when files get moved. 但是,当文件移动时,您将失去rsyncssh提供的带宽效率。

The following issue on GitHub helped to me solve the same problem: https://github.com/axkibe/lsyncd/issues/369 GitHub上的以下问题帮助我解决了同样的问题: https//github.com/axkibe/lsyncd/issues/369

What I did was quite simple, I just replaced default.rsyncssh with default.rsync in lysync.conf.lua file 我做的很简单,我刚用lysync.conf.lua文件中的default.rsync替换default.rsyncssh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM