0

我正在为我的系统(archlinux)上的一些用户设置一个 sshd 监狱。在不深入细节的情况下,我想尽量减少问题的范围。

设置/etc/ssh/sshd_config

Match group jaileduser
          ChrootDirectory /var/jailedusers
          X11Forwarding no
          AllowTcpForwarding no

和类似的系统/etc/password条目:

testuser1:x:2001:2000::/home/testuser1:/bin/bash

所以问题是: 主目录是/home/testuser1相对于sshd_config条目/var/jailedusers的,即 passwd 条目应该是/var/jailedusers/home/testuser1还是其中的/home/testuser1目录- 并且是同一条船上的外壳 - 是 passwd 条目还是简单的。/var/jailedusers/home/testuser1/var/jailedusers/bin/bash/bin/bash

最后登录时系统/etc/passwd读取或/var/jailedusers/etc/passwdsshd_config条目读取。

4

1 回答 1

1

基于手册页:

Specifies the pathname of a directory to chroot(2) to after
authentication.  All components of the pathname must be root-
owned directories that are not writable by any other user or
group.  After the chroot, sshd(8) changes the working directory
to the user's home directory.

因此/etc/passwd需要包含相对于系统根目录(即/bin/bash/home/testuser1)的路径,并且系统根目录在 chroot 之后实际上是/var/jailedusers(这意味着这/var/jailedusers/home/testuser1将是实际的主目录和/var/jailedusers/bin/bash实际的外壳)。

要回答问题的第二部分,sshd将阅读/etc/passwd、执行身份验证,然后chroot执行/var/jailedusers

请注意,/var/jailedusers还需要包含其他文件,例如所需的共享库bash和最小的/dev条目集(例如/dev/null)。

于 2014-02-27T00:05:24.850 回答