unit9 vsftpd服务
1.本地用户设定
local_enable=YES|NO ##本地用户登陆限制
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> ls
-rw-r--r-- 1 0 0 0 Apr 10 05:25 filestudent
-rw-r--r-- 1 1000 1000 2339 Apr 10 10:42 passwd
-rw-r--r-- 1 0 0 12288 Apr 10 06:23 userfile.db
write_enable=YES|NO ##本地用户写权限限制
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> put /etc/passwd
2339 bytes transferred
lftp student@172.25.254.137:~> quit
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
#<本地用户家目录修改
>
local_root=/directory
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# touch /mnt/file
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> ls
-rw-r--r-- 1 0 0 0 Apr 11 06:32 file
-rwxrwxrwx 1 0 0 0 Apr 11 06:12 file1
lftp student@172.25.254.137:~>
#<
限制本地用户浏览
/目录
>
所有用户被锁定到自己的家目录中
chroot_local_user=YES
chmod u-w /home/*
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# chmod u-w /home/*
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> ls /
-rw-r--r-- 1 0 0 0 Apr 10 05:25 filestudent
-rw-r--r-- 1 1000 1000 2339 Apr 11 05:55 passwd
-rw-r--r-- 1 0 0 12288 Apr 10 06:23 userfile.db
lftp student@172.25.254.137:/>
用户黑名单建立
chroot_local_user=NO ##不锁定本地用户
chroot_list_enable=YES ##锁定列表
chroot_list_file=/etc/vsftpd/chroot_list
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# vim /etc/vsftpd/chroot_list
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> ls /
-rw-r--r-- 1 0 0 0 Apr 10 05:25 filestudent
-rw-r--r-- 1 1000 1000 2339 Apr 11 05:55 passwd
-rw-r--r-- 1 0 0 12288 Apr 10 06:23 userfile.db
用户白名单建立
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# vim /etc/vsftpd/chroot_list
[root@localhost ~]# systemctl restart vsftpd
[root@localhost ~]# lftp 172.25.254.137 -u student
Password:
lftp student@172.25.254.137:~> ls
-rw-r--r-- 1 0 0 0 Apr 10 05:25 filestudent
-rw-r--r-- 1 1000 1000 2339 Apr 11 05:55 passwd
-rw-r--r-- 1 0 0 12288 Apr 10 06:23 userfile.db
lftp student@172.25.254.137:~> ls /
lrwxrwxrwx 1 0 0 7 May 07 2014 bin -> usr/bin
dr-xr-xr-x 4 0 0 4096 Jul 10 2014 boot
drwxr-xr-x 18 0 0 2800 Apr 11 05:47 dev
drwxr-xr-x 135 0 0 8192 Apr 11 01:47 etc
drwxr-xr-x 5 0 0 42 Apr 10 07:02 ftpusers
dr-xr-xr-x 9 0 0 98 Apr 06 06:12 home
lrwxrwxrwx 1 0 0 7 May 07 2014 lib -> usr/lib
lrwxrwxrwx 1 0 0 9 May 07 2014 lib64 -> usr/lib64
drwxr-xr-x 2 0 0 6 Mar 13 2014 media
drwxrwxrwx 2 0 0 29 Apr 11 06:32 mnt
drwxr-xr-x 3 0 0 15 Jul 10 2014 opt
dr-xr-xr-x 137 0 0 0 Apr 11 01:47 proc
drwxr-xr-x 2 0 0 6 Apr 06 10:03 pub
-rwxrwxrwx 1 0 0 0 Apr 01 10:26 public
dr-xr-x--- 20 0 0 4096 Apr 11 07:10 root
drwxr-xr-x 36 0 0 1140 Apr 11 06:05 run
lrwxrwxrwx 1 0 0 8 May 07 2014 sbin -> usr/sbin
drwxr-xr-x 3 0 0 4096 Mar 31 10:26 software
drwxr-xr-x 2 0 0 6 Mar 13 2014 srv
dr-xr-xr-x 13 0 0 0 Apr 11 05:47 sys
drwxrwxrwt 51 0 0 4096 Apr 11 05:48 tmp
drwxr-xr-x 13 0 0 4096 May 07 2014 usr
drwxr-xr-x 24 0 0 4096 Apr 11 01:47 var
#<
限制本地用户登陆
>
vim /etc/vsftpd/ftpusers ##用户黑名单
vim /etc/vsftpd/user_list ##用户临时黑名单
用户白名单设定
userlist_deny=NO
/etc/vsftpd/user_list ##参数设定,此文件变成用户白名单,只在名单中出现的用户可以登陆
ftp
#<ftp虚拟用户的设定
>
创建虚拟帐号身份
)
vim /etc/vsftpd/loginusers ##文件名称任意
ftpuser1
123
ftpuser2
123
ftpuser3
123
db_load -T -t hash -f /etc/vsftpd/loginusers loginusers.db
vim /etc/pam.d/ckvsftpd ##文件名称任意
account required pam_userdb.so db=/etc/vsftpd/loginusers
auth required pam_userdb.so db=/etc/vsftpd/loginusers
vim /etc/vsftpd/vsftpd.conf
pam_service_name=ckvsftpd
guest_enable=YES
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# vim /etc/vsftpd/usersfile
[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# db_load -T -t hash -f /etc/vsftpd/usersfileusersfile.db
[root@localhost vsftpd]# vim /etc/pam.d/ckvsftpd
[root@localhost vsftpd]# vim /etc/vsftpd/vsftpd.conf [root@localhost vsftpd]#systemctl restart vsftpd[root@localhost vsftpd]# lftp 172.25.254.137 -uuser1
Password:
lftp user1@172.25.254.137:~> ls