使用 rsync 备份 gitosis 存储库?

发布于 2024-09-04 18:15:46 字数 508 浏览 8 评论 0原文

我有一个标准的 gitosis 设置,我想使用 rsync 进行备份。当我尝试:

rsync -avz [email protected]:/home/git git_origin/

rsync -avz --rsync-path 'sudo rsync' 192.168.0.2:/home/git git_origin/

它不处理任何存储库文件。很确定这与“git”用户没有密码并完全拥有 /home/git/repositories 目录结构中所有文件的所有权有关。由于您无法“ssh git”或“su git”,我无法达到正确的权限级别。

那么,如何使用 rsync 备份我的所有 gitosis 存储库?

I have a standard gitosis setup that I would like to backup using rsync. When I try:

rsync -avz [email protected]:/home/git git_origin/

or

rsync -avz --rsync-path 'sudo rsync' 192.168.0.2:/home/git git_origin/

It copes no repository files. Pretty sure it has to do with how the 'git' user has no password and complete ownership of all files in it's /home/git/repositories directory structure. Since you can't 'ssh git' or 'su git' I can't achieve the correct permission level.

So, how do I use rsync to backup all my gitosis repositories?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挽你眉间 2024-09-11 18:15:46

IMO 最简单的方法是将自定义密钥添加到 git 用户的 authorized_keys 文件中。

### auto generated by gitosis, DO NOT EDIT 行上方添加一个条目,以 root 用户身份在 /home/git/.ssh/authorized_keys 下(在大多数情况下) Linux 系统),你应该可以开始了。默认情况下,Gitosis 在重新生成时会忽略 authorized_keys 文件的自定义条目。

如果您想进一步锁定服务器,您可以随时在密钥输入之前添加自定义 command= 指令,谷歌搜索“rsync ssh lock down”会为您提供http://sixohthird.com/1458/locking-down-rsync-using-ssh 作为第一个命中,其中应该可以帮助你开始。

通过 rsync 抓取文件而不跳过一些随机用户切换环(如 user->root->git 切换)的唯一其他方法是使用 ssh 以 root 用户身份连接并使用它抓取文件。

通过提供自定义 authorized_keys 条目,以 root 用户身份运行并以 git 用户身份进行 ssh 操作,都应该为您提供访问要 rsync 的文件所需的权限。

Easiest way IMO would be to add a custom key into your authorized_keys file for the git user.

Add in an entry above the line that says ### autogenerated by gitosis, DO NOT EDIT as the root user under /home/git/.ssh/authorized_keys (on most Linux systems) and you should be good to go. Gitosis by default ignores custom entries to the authorized_keys file when regenerating it.

If you want to lock the server down more, you can always add a custom command= directive before the key entry, googling "rsync ssh lock down" gives you http://sixohthree.com/1458/locking-down-rsync-using-ssh as the first hit, which should get you started.

The only other way of grabbing the files over rsync without jumping through some random user switching hoops (as in user->root->git switches) would be to use ssh to connect as the root user and grab the files with it.

Both running as the root user and ssh'ing as the git user by providing a custom authorized_keys entry should give you the permissions you need to access the files you want to rsync.

你又不是我 2024-09-11 18:15:46

gitolite 将 rsync 列为它可以提供授权的受支持外部命令之一。

我还没有这样做,但我相信您可以使用允许在每个存储库上使用 rsync 的特定 ssh 密钥进行设置。第一步是在 gitolite.rc 文件中设置 $RSYNC_BASEexample.conf 显示了如何指定 rsync 的权限。

如果你想知道为什么我回答 gitolite 而不是 gitosis,gitosis 是不维护的,不推荐使用的,并且已经死了,停止使用它并切换到 gitolite

gitolite lists rsync as one of the supported external commands that it can provide authorization for.

I have not done this but I believe you can set this up with a specific ssh key allowed to use rsync on every repository. The first step is setting $RSYNC_BASE in the gitolite.rc file. The example.conf shows how to specify permissions for rsync.

And encase you are wondering why I answered about gitolite instead of gitosis, gitosis is unmaintained, deprecated, and dead, stop using it and switch to gitolite.

同尘 2024-09-11 18:15:46

我正在使用这个 脚本开始我的自定义脚本,它正在使用

--rsync-path='sudo /usr/bin/rsync'

也许这可以帮助?

I was using this script for a start for my customized scripts, and it is using

--rsync-path='sudo /usr/bin/rsync'

Maybe that could help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文