OpenSSH 与 AIX chroot
2008-07-07 08:19:01 来源:WEB开发网设置 <chroot-user> 的密码,然后在用户 shell 中更改它:
/home/chroot # passwd smile
Changing password for "smile"
smile's New password:
Enter the new password again:
/home/chroot # su - smile
$ passwd
Changing password for "smile"
smile's Old password:
smile's New password:
Enter the new password again:
$ exit
将 <chroot-user> 条目从 /etc/passwd 和 /etc/group 复制到 chroot 环境的相关文件中:
/home/chroot # cat /etc/passwd | grep smile >> /home/chroot/etc/passwd
/home/chroot # cat /etc/group | grep smile >> /home/chroot/etc/group
/home/chroot # cat /home/chroot/etc/passwd
smile:!:397:1:chroot test user:/home/chroot/./home/smile/:/usr/bin/ksh
/home/chroot # cat /home/chroot/etc/group
staff:!:1:ipsec,dasusr1,db2inst1,db2fenc1,idsldap,ldapdb2,ftp,anonymou,aroell,
ldap,ituam,ski,usrsftp,sshd,bm,smile
现在,已完成 chroot 环境的设置,并可与 ssh、sftp 和 scp 一起使用,例如:
lp2:root:/root # sftp smile@lp5
Connecting to lp5...
smile@lp5's password:
sftp> ls
sftp> put smit.log
Uploading smit.log to /home/smile/smit.log
smit.log 100% 203KB 203.1KB/s 00:00
sftp> ls -al
drwxr-xr-x 2 smile staff 256 Feb 1 18:32 .
drwxr-xr-x 3 0 0 256 Feb 1 18:15 ..
-rwxr----- 1 smile staff 254 Feb 1 18:15 .profile
-rw-r--r-- 1 smile staff 207951 Feb 1 18:32 smit.log
sftp> quit
lp2:root:/root # ssh smile@lp5
smile@lp5's password:
Last login: Fri Feb 1 18:32:19 NFT 2008 on ssh from X.YYY.ZZZ.77
$ ls -al
total 424
drwxr-xr-x 2 smile staff 256 Feb 1 18:33 .
drwxr-xr-x 3 0 0 256 Feb 1 18:15 ..
-rwxr----- 1 smile staff 254 Feb 1 18:15 .profile
-rw------- 1 smile staff 10 Feb 1 18:33 .sh_history
-rw-r--r-- 1 smile staff 207951 Feb 1 18:32 smit.log
$ cp smit.log test.out
$ rm smit.log
$ ls -al
total 432
drwxr-xr-x 2 smile staff 256 Feb 1 18:33 .
drwxr-xr-x 3 0 0 256 Feb 1 18:15 ..
-rwxr----- 1 smile staff 254 Feb 1 18:15 .profile
-rw------- 1 smile staff 54 Feb 1 18:33 .sh_history
-rw-r--r-- 1 smile staff 207951 Feb 1 18:33 test.out
$ exit
Connection to lp5 closed.
lp2:root:/root # scp smile@lp5:/home/smile/test.out .
smile@lp5's password:
test.out 100% 203KB 203.1KB/s 00:00
lp2:root:/root # ls -al test.out
-rw-r--r-- 1 root system 207951 Feb 01 18:38 test.out
chrooted 用户的各种身份验证方法
PAM 身份验证:将 /usr/lib/security/pam_aix 复制到 chrooted 定向的目录中,例如:# cp /usr/lib/security/pam_aix <chroot-dir>/usr/lib/security/
公钥身份验证:将 chrooted 用户的公钥文件复制到下述路径中:/home/<chroot-dir>/home/<chroot-user>/.ssh/authorized_keys
更多精彩
赞助商链接