<返回更多

centos8 vsftpd配置虚拟用户认证

2020-08-05    
加入收藏

1、建立Vsftpd虚拟宿主用户

useradd vftp -M -s /sbin/nologin -d /var/ftp/

2、创建虚拟用户的文件

[root@localhost vsftpd]# cat /etc/vsftpd/virtusers test test123456

3、生成虚拟用户口令文件和认证文件

db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db chmod 400 vuser_list.db

4、添加认证

[root@localhost vsftpd]# cat /etc/pam.d/vsftpd
#%PAM-1.0
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_list
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser_list

#session    optional     pam_keyinit.so    force revoke
#auth       required	pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
#auth       required	pam_shells.so
#auth       include	password-auth
#account    include	password-auth
#session    required     pam_loginuid.so
#session    include	password-auth

5、vsftpd.conf配置

mkdir /etc/vsftpd/vconf
mkdir /var/ftp/virtual
mkdir /var/ftp/virtual/test
chown -R vftp.vftp /var/ftp/virtual/

[root@localhost vsftpd]# cat vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=NO
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to FTP Server
chroot_local_user=YES
ls_recurse_enable=NO
listen=YES
hide_ids=YES
pam_service_name=vsftpd
userlist_enable=NO
guest_enable=YES
guest_username=vftp
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vconf

6、配置虚拟用户配置

[root@localhost vsftpd]# cat /etc/vsftpd/vconf/test 
local_root=/var/ftp/virtual/test
anonymous_enable=NO
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
idle_session_timeout=600
data_connection_timeout=120
max_clients=10
max_per_ip=5
local_max_rate=50000
allow_writeable_chroot=YES 

7、重启服务|测试

[root@localhost vsftpd]# systemctl restart vsftpd
[root@localhost vsftpd]# ftp
ftp> open 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 Welcome to FTP Server
Name (127.0.0.1:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,65,5).
150 Here comes the directory listing.
226 Directory send OK.
ftp> dir
227 Entering Passive Mode (127,0,0,1,181,149).
150 Here comes the directory listing.
226 Directory send OK.
ftp> 
 
声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>