限制 OpenSSH 仅允许上传到某些目录

发布于 2024-07-14 21:10:19 字数 402 浏览 4 评论 0原文

我需要从多个服务器运行备份到另一台服务器上的单个帐户。 如果其中一台公共服务器受到损害,我不希望备份帐户上的另一台服务器的文件受到损害。

我需要做的只是根据传入连接的 ssh 密钥允许 SCP 访问特定目录。

我知道我可以在authorized_keys 文件中设置 shell 和每个密钥的几个选项。 http://www.manpagez.com/man/8/sshd/ (向下滚动到“AuthorizedKeysFile”)

我不知道如何将内部 sftp 命令设置为仅使用某个目录。 我的机器上没有 root,所以我无法执行正常的内部 sftp + chroot。

I need to run backups from multiple servers to a single account on another server. If one of the public servers is compromised, I don't want the other server's files on the backup account compromised.

What I need to do is only allow SCP to a specific directory, based on the ssh key of the incoming connections.

I know that I can set the shell, and several options on a per key basis in the authorized_keys file. http://www.manpagez.com/man/8/sshd/ (Scroll down to "AuthorizedKeysFile")

What I don't know how to set the internal-sftp command to only use a certain directory. I don't have root on the the machine, so I can't do the normal internal-sftp + chroot.

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

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

发布评论

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

评论(1

毁我热情 2024-07-21 21:10:19

事实并非如此。

您需要做的是为每个备份主机设置一个迷你 chroot 监狱。 它只需要能够运行 sh 和 scp (/dev 只需要 /dev/null 条目)。

使用 jailsh 作为每个帐户的登录 shell。

Jailsh 是一个 suid-root 登录 shell,它将 chroot Jail 设置为由两个连续斜杠标记的目录,删除 root 权限,并执行 /bin/sh。

It doesn't work that way.

What you need to do is set up a mini chroot jail for each backup host. It just needs to be able to run sh and scp (/dev only needs /dev/null entry).

Use jailsh as the login shell for each account.

Jailsh is a suid-root login shell that sets chroot jail to the directory marked by two consecutive slashes, drops root privs, and execs /bin/sh.

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