整个文件系统的备份权限

这里的瘦:我有一个Linode的VPS,我想通过rsync备份到我的本地笔记本电脑。 我刚刚为通信生成了ssh密钥,并留下了私钥的空白密码,所以我可以通过cron的rsync而不用担心密码。

为了额外的安全性,我也拒绝了root sshlogin。 理想情况下,我想备份从/下来的一切,但这是不可能使用普通用户,除非我给一个特定的用户rwx访问的一切。

什么是最好的方式来通过rsync备份整个文件系统,而不允许rootlogin?

使用root帐户:只有uid 0可以读取整个文件系统。

现在,当您想要提高安全性时,您可以执行以下操作:

  • 不允许root通过ssh使用密码login(在sshd config中,PermitRootLogin不带密码)。
  • 使用密钥authentication进行备份。

根据man 5 sshd_config :

" PermitRootLogin Specifies whether root can log in using ssh(1). The argument must be ``yes'', ``without-password'', ``forced-commands-only'', or ``no''. The default is ``yes''. If this option is set to ``without-password'', password authentication is disabled for root. If this option is set to ``forced-commands-only'', root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root. If this option is set to ``no'', root is not allowed to log in." 

从来没有尝试过“强制命令只”参数,但它看起来很有趣。

您可以在远程服务器上以守护进程模式运行rsync,并通过在客户端使用以下命令来备份所需的任何分区/文件夹:

 rsync -au rsync://[email protected]:/folder /path/to/dest 

但是,您需要以下内容:

  1. 在远程服务器上以守护进程模式运行rsync。
  2. 您需要在您和远程服务器之间打开端口873。
  3. 您需要在/etc/rsyncd.conf定义远程服务器上的模块[folder]

要处理安全/encryption部分,您可以设置一些隧道或VPN。 例如,您可以使用以下命令设置隧道SSH:

 sudo ssh -L 873:your.server.ip.addr:873 [email protected] 

一旦build立了隧道,就可以在本地使用rsync,连接将通过隧道转发到远程服务器。

 rsync -au rsync://user@localhost:/folder /path/to/dest 

在这种情况下,由于端口22上的SSH通过隧道连接,所以不需要公开端口873。

如何把用户放入根组?

我相信根组将能够读取其他文件,类似于root。