用户黑白名单
一个Linux主机中会多个用户,而我们希望有些用户不能去访问ftp。ftp服务器可以通过配置文件“/etc/vsftpd/user_list”来设置一个用户列表,这个列表可以是黑名单,也可以是白名单,具体要根据配置文件的参数“userlist_deny”来确定
1
、黑名单
1
)修改配置文件“/etc/vsftpd/vsftpd.conf”中的参数“userlist_enable”,确保这个参数是yes
[ro
ot@localhost wj]#
gedit
/etc/vsftpd/vsftpd.conf
//
匿名登录
userlist_enable=YES
|
2
)打开配置文件“/etc/vsftpd/vsftpd.conf“,在末尾追加一句话”userlist_deny=yes“。这个参数是yes,表示要设置一个黑名单
[root@localhost wj]#
lftp david:543092@192.168.0.113:8765
//
用户
david
登录,密码是
543092
userlist_deny=YES
|
3
)编辑文件“/etc/vsftpd/user_list“,在末尾追加一句话要设置的用户名即可
[root@localhost ~]#
gedit /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
david
|
4
)重启服务,测试黑名单内的用户是否可以访问,上面列出的都是不可以访问的用户
[root@localhost wj]#
service vsftpd restart //
重启服务
关闭
vsftpd
:
[
失败
]
为
vsftpd
启动
vsftpd
:
[
确定
]
[root@localhost wj]#
lftp weijie:123456@192.168.0.113:8765 //
用户
weijie
登录,可以访问
lftp weijie@192.168.0.113:~> ls
-rwxrwxrwx 1 0 0 2375494044 Aug 14 07:13 1.zip
lftp weijie@192.168.0.113:~> bye
[root@localhost wj]#
lftp 192.168.0.113:8765
//
匿名用户也可以
lftp 192.168.0.113:~> ls
drwxr-xr-x 2 0 0 4096 Aug 14 06:38 pub
lftp 192.168.0.113:/>
[root@localhost wj]#
lftp david:543092@192.168.0.113:8765 //
用户
david
在黑名单中,因此无法访问,
ls
命令会失败
lftp david@192.168.0.113:~> ls
[0] ls &
`ls' at 0 [
重新连接前延时
: 28]
lftp david@192.168.0.113:~>
|
2
、白名单
1
)修改配置文件“/etc/vsftpd/vsftpd.conf”中的参数“userlist_enable”,确保这个参数是yes
[ro
ot@localhost wj]#
gedit
/etc/vsftpd/vsftpd.conf
//
匿名登录
userlist_enable=YES
|
2
)打开配置文件“/etc/vsftpd/vsftpd.conf“,在末尾追加一句话”userlist_deny=NO“。这个参数是NO,表示要设置一个白名单
[root@localhost wj]#
lftp david:543092@192.168.0.113:8765
//
用户
david
登录,密码是
543092
userlist_deny=NO
|
3
)编辑文件“/etc/vsftpd/user_list“,在末尾追加一句话要设置的用户名即可
[root@localhost ~]#
gedit /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
david
|
4
)重启服务,测试黑名单内的用户是否可以访问,上面列出的都是不可以访问的用户
[root@localhost wj]#
service vsftpd restart //
重启服务
关闭
vsftpd
:
[
失败
]
为
vsftpd
启动
vsftpd
:
[
确定
]
[root@localhost wj]#
lftp david:543092@192.168.0.113:8765 //
用户
david
登录,可以访问
lftp weijie@192.168.0.113:~> ls
-rwxrwxrwx 1 0 0 2375494044 Aug 14 07:13 1.zip
lftp weijie@192.168.0.113:~> bye
[root@localhost wj]#
lftp weijie:123456@192.168.0.113:8765 //
用户
weijie
不在白名单中,因此无法访问,
ls
命令会失败
lftp david@192.168.0.113:~> ls
[0] ls &
`ls' at 0 [
重新连接前延时
: 28]
lftp david@192.168.0.113:~> bye
[root@localhost wj]#
lftp 192.168.0.113:8765
//
匿名用户也不行
lftp 192.168.0.113:~> ls
[0] ls &
`ls' at 0 [
重新连接前延时
: 28]
lftp 192.168.0.113:~>
|
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。