gpt4 book ai didi

linux - 相对于sshd jail root的文件结构

转载 作者:太空宇宙 更新时间:2023-11-04 11:13:34 27 4
gpt4 key购买 nike

我正在为我的系统 (archlinux) 上的一些用户设置一个 sshd jail 。在不深入细节的情况下,我想将问题的范围缩小。

设置/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/home/testuser1/var/jailedusers 中有一个目录 - 并且是同一条船上的 shell - 是 passwd 条目 /var/jailedusers/bin/bash 或简单地 /bin/bash

最后登录时系统 /etc/passwd 读取或 /var/jailedusers/etc/passwd 根据 sshd_config 条目读取.

最佳答案

基于手册页:

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 实际的 shell)。

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

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

关于linux - 相对于sshd jail root的文件结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22056040/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com