温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux服务器---ftp黑名单

发布时间:2020-08-19 00:35:50 来源:ITPUB博客 阅读:161 作者:一生有你llx 栏目:建站服务器

用户黑白名单

一个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:~> 

 

 

 



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI