Restrict local users to browse the root directory
/etc/vsftpd/vsftpd.conf
Function: All users are locked into their own plus directory (not only in their own home directory, you can also look at other before modification)
Edit Limits browse the root user
vim / etc / vsftpd / chroot_list
add whitelist setting
chroot_local_user = YES --- > this parameter requires write permissions to add themselves to remove the directory
chroot_list_enable = YES
chroot_list_file = / etc / vsftpd / chroot_list ---> list the file path
users listed in / etc / vsftpd / chroot_list file, you can switch to a different directory
Note ---> user is not listed in the document, you can not switch to another directory
Blacklist provided
chroot_local_user = NO
chroot_list_enable = YES
the chroot_list_file = / etc / the vsftpd / chroot_list ---> List file path
Users listed in the / etc / vsftpd / chroot_list file, can not switch to another directory
Note ---> user is not listed in the document, you can switch to another directory
.
限制本地用户登录
功能:限制本地用户登录
注 ---> 限制本地用户设置
vim /etc/vsftpd/ftpusers 只默认黑名单设置 ---> 永久用户黑名单
vim /etc/vsftpd/user_list 白黑名单均可设置 ---> 用户临时黑名单
用户黑名单建立
userlist_enable=YES
黑名单设置vim /etc/vsftpd/user_list ---> 用户临时黑名单
只默认黑名单 vim /etc/vsftpd/ftpusers ---> 永久用户黑名单
其他用户可登录
用户白名单建立
userlist_enable=YES
userlist_deny=NO ---> 白名单功能建立
用户白名单设定
vim /etc/vsftpd/user_list ##参数设定,此文件变成用户白名单,只在名单中出现的用户可以登录ftp
只有白名单tom可以登录
其他用户都不能登录
.
ftp虚拟用户的设定
(创建虚拟帐号身份)
vim /etc/vsftpd/testfile ---> 文件名称任意
user1
111
user2
222
user3
333
db_load -T -t hash -f /etc/vsftpd/testfile /etc/vsftpd/testfile .db
注 ---> 上面的密码是明文的,不安全,要进行加密,T表示transfer,t表示转换方式为hash
查看文件类型
ps aux | grep pam
注 ---> 系统里有pam这个进程的
cd /etc/pam.d ---> 查看vsftpd.conf,认证的时候是使用pam认证
注 ---> cd /etc/pam.d,目录里有个vsftpd文件
---> 认证的时候就是在这个文件里做用户名和密码的比对
vim test
account required pam_userdb.so db=/etc/vsftpd/testfile
auth required pam_userdb.so db=/etc/vsftpd/testfile
注 ---> account表示帐号名称,auth表示密码,先后顺序不分
---> required是通过了用户名认证才能进入下一步认证,然后使用pam_userdb.so这个插件来验证
---> db=/etc/vsftpd/testfile 文件后不要写.db,系统会自动加
创建虚拟帐号身份
vim /etc/vsftpd/vsftpd.conf
虚拟帐号认证参考test认证文件
pam_service_name=test
开启虚拟账户功能
guest_enable=YES
虚拟帐号没有身份指定时,登录共享目录
虚拟帐号身份指定
设置家
guest_username=tom
注 ---> 默认使用虚拟用户时,登录后在pub目录,要想改变,修改此参数,修改后登录到tom家目录
chmod u-w /home/ftpuser
虚拟帐号家目录独立设定
vim /etc/vsftpd/vsftpd.conf
local_root=/ftphome/$USER
user_sub_token=$USER
vim /etc/vsftpd/vsftpd.conf
注 ---> $USER是shell里的用法,要让配置文件里支持,必须加这个参数
创建user1,2的家目录
mkdir /ftphome/user1/pub1 -p
mkdir /ftphome/user2/pub2 -p
改目录权限为775,组为ftp
chgrp ftp /ftphome /user1/pub1
chgrp ftp /ftphome /user2/pub2
chmod 775 /ftphome/user1/pub1
chmod 775 / ftphome / user2 / pub2
virtual account configured independently
to create a configuration file
mkdir -p / etc / vsftpd / userconf
profile user1 set
vim / etc / vsftpd / userconf / user1
Note ---> set the configuration file in this file All parameters, a higher priority for this file
anon_upload_enable = YES
user1 can upload
user2 not