目的是:在linux系统上建立ftp用户,并限制其通过ftp访问时,只能访问用户主目录;其主目录显示路径也是“/”,看不到上级目录。
例如,我要建立用户usertest,密码为usertest,主目录为/home/mpsp/ftp/usertest
操作系统:Red Hat Enterprise Linux Server release 5.4 (Tikanga)
ftp:vsftp
首先,建立linux系统用户usertest:
1、以mpsp用户登陆系统,建立usertest的主目录/home/mpsp/ftp/usertest
2、以root用户登录linux系统,建立带有主目录的用户,输入命令:
[root@- home]# useradd -d /home/mpsp/ftp/usertest usertest
3、 为用户分配密码,输入命令:
[root@- etc]# passwd usertest
Changing password for user usertest.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
此时查看:[root@- etc]# cat /etc/passwd
可看到用户配置是这样的:usertest:x:504:504::/home/mpsp/ftp/usertest:/bin/bash
系统为用户分配了新的用户id和组id:504、504。由于该用户的所有文件需对mpsp用户开放访问权限,我们可以将usertest分配到mpsp组(组id500)。
4、为用户分配新的用户组,输入命令:
[root@- home]# usermod -g mpsp usertest
此时查看:[root@- etc]# cat /etc/passwd
可看到用户配置是这样的:usertest:x:504:500::/home/mpsp/ftp/usertest:/bin/bash
然后,配置用户ftp权限及访问路径限制:
此时用usertest登陆系统ftp,是否可以访问?如果无法访问,说明我们的ftp做了限制。打开/etc/vsftpd/vsftpd.conf,查找userlist_enable、userlist_deny、userlist_fi