Skip to content

Instantly share code, notes, and snippets.

@naoaki011
Last active April 4, 2021 06:39
Show Gist options
  • Save naoaki011/4fbcca51372e869716def303c5d98ff6 to your computer and use it in GitHub Desktop.
Save naoaki011/4fbcca51372e869716def303c5d98ff6 to your computer and use it in GitHub Desktop.
lsyncd rsync (rsyncssh ではファイルのmvが反映されない模様)
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.status",
statusInterval = 1
}
-- /var/www/html
sync {
default.rsync,
source = "/var/www/html/",
target = "syncuser@10.0.0.4:/var/www/html/",
exclude = "/log",
delay = 0,
delete = "running",
init = false,
rsync = {
rsync_path = "sudo /usr/bin/rsync",
rsh = "/usr/bin/ssh -l syncuser -i /home/syncuser/.ssh/syncuser.pem -p 22 -o StrictHostKeyChecking=no",
owner = true,
group = true,
perms = true
}
}
@naoaki011
Copy link
Author

前提として

  • syncuser はパスワード無しで sudo 可能
  • syncuser はパスフレーズなしの鍵認証でログイン可能
  • syncuser にはパスワードが設定されていない

@naoaki011
Copy link
Author

naoaki011 commented Mar 8, 2021

よりセキュリティを高めるには、/etc/ssh/sshd_config に AllowUsers で syncuser@10.0.0.4 のみに制限するなど。
その場合、全ユーザに対して制限がかかるので、以下のようにログインする必要があるユーザ名を羅列する。

AllowUsers  ec2-user
AllowUsers  syncuser@10.0.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment