补丁 148104-16 (Sparc) 和 148105-16 (x86) 以及这些补丁的更新版本引入了新的 sshd_config 关键字“Match”,可用于将 chroot 设置限制为特定用户、组或者其他选择标准。
此示例仅在我们安装了前面提到的必需补丁的情况下才有效。
我们可以使用命令“showrev -p | grep 148104”(或者 x86 的情况下为 148105)来检查并确保版本 -16 或者更新版本可用。
本示例将为 testuser 设置一个 chroot 环境,而不会影响其他用户。
请注意,必须在 sshd_config 文件的末尾添加 Match 关键字,并且在一个 Match 子句之后的所有行都属于一起,直到新的 Match 块开始或者到达文件末尾。
- 使用 ftpconfig 命令创建目标 chroot 环境:
# mkdir /export/home/chroot # ftpconfig -d /export/home/chroot/testuser Creating directory /export/home/chroot/testuser Updating directory /export/home/chroot/testuser
- 创建用户并分配密码:
# useradd -d /export/home/chroot/testuser testuser # passwd testuser New Password: Re-enter new Password: passwd: password successfully changed for testuser
- 在文件/etc/ssh/sshd_config中加入如下chroot配置行
# vi /etc/ssh/sshd_config Match User testuser ChrootDirectory /export/home/chroot/testuser
确保配置位于 sshd_config 文件的末尾。
- 重启ssh服务激活配置更改:
# svcadm restart ssh
日期:2020-09-17 00:15:14 来源:oir作者:oir