2007年6月4日星期一

在HP-UX下建立只归属于某个目录下的ftp账户

如何建立一个只归属于某个目录下的ftp账户?如ftptest通过ftp登陆到系统时,
系统认为/home/ftptest就是他的根(/)。

以下方法在hpux11下测试通过,如在hpux下实现此功能,需要安装wu_ftp这个软 件,或者更新你的ftp。

假设要在系统中建立一个ftptest(属于ftptest组),要想在它ftp的时候始终在
/home/ftptest目录以及它的子目录下。下面是他的建立步骤。

1。在/etc/passwd中建立相应的ftptest条目,注意他的主目录的写法:
ftptest:Aci$xi:555:555:ftp user for chroot:/home/ftptest/./:/bin/ksh
(确信/etc/shells中有/bin/ksh,否则请加上,密码由你自己决定 )
2。在/etc/passwd中建立相应的组ftptest
ftptest::555:ftptest
3。建立/home/ftptest以及相应的目录(主要是~ftp/usr/bin和~/ftp/etc)
#mkdir /home/ftptest
#chown ftptest:ftptest /home/ftptest
#su - ftptest
$pwd //make sure it is under /home/ftptest
$mkdir -p usr/bin
$cp /sbin/ls usr/bin ; cp /bin/pwd usr/bin
$mkdir etc
$cp /etc/passwd etc ; cp /etc/group etc (为了安全,你需要修改passwd中
不必要的项,如root)
4。编辑/etc/inetd.conf
确信ftp的那一行是这样写的:
ftp stream tcp nowait root /usr/lbin/ftpd ftp -l -a (一定要加上 -a 这
个参数)
5。重新初始化inetd : 执行: inetd -c
6。产生相应的ftpaccess/ftpgroups文件
#cd /etc/ftpd
#touch ftpgroups
#vi ftpaccess //这个文件的内容大致如下:


class all real,guest,anonymous *

# Define the line that limits the ftponly group to their own directories

# in the ftp-root heirarchy.
guestgroup ftptest //这里要和你的组ftptest一致。

email xxxx@xxxx.com //这里用你自己的email地址

loginfails 5

readme README* login
readme README* cwd=*

message /welcome.msg login
message .message cwd=*

compress yes all
tar yes all
chmod no guest,anonymous
delete no guest,anonymous
overwrite no guest,anonymous
rename no guest,anonymous

log transfers anonymous,real inbound,outbound

shutdown /etc/shutmsg

passwd-check rfc822 warn

0 评论: