Linux伺服器---ftp黑名單

一生有你llx發表於2018-12-09

使用者黑白名單

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

 

 

 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29270124/viewspace-2221910/,如需轉載,請註明出處,否則將追究法律責任。

相關文章