天天看點

Linux伺服器配置---ftp使用者黑名單

使用者黑白名單

      一個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:[email protected]: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:[email protected]:8765     //​

​​

​使用者​

​​

​weijie​

​​

​登入,可以通路​

​lftp [email protected]:~> ls​

​-rwxrwxrwx    1 0        0        2375494044 Aug 14 07:13 1.zip​

​lftp [email protected]:~> 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:[email protected]:8765    //​

​​

​使用者​

​​

​david​

​​

​在黑名單中,是以無法通路,​

​​

​ls​

​​

​指令會失敗​

​lftp [email protected]:~> ls​

​[0] ls &                                 ​

​    `ls' at 0 [​

​​

​重新連接配接前延時​

​​

​: 28]​

​lftp [email protected]:~>​

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:[email protected]: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:[email protected]:8765     //​

​​

​使用者​

​​

​david​

​​

​登入,可以通路​

​lftp [email protected]:~> ls​

​-rwxrwxrwx    1 0        0        2375494044 Aug 14 07:13 1.zip​

​lftp [email protected]:~> bye​

​[root@localhost wj]# lftp weijie:[email protected]:8765    //​

​​

​使用者​

​​

​weijie​

​​

​不在白名單中,是以無法通路,​

​​

​ls​

​​

​指令會失敗​

​lftp [email protected]:~> ls​

​[0] ls &                                 ​

​    `ls' at 0 [​

​​

​重新連接配接前延時​

​​

​: 28]​

​lftp [email protected]:~> 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:~> ​

 做了一個Linux學習的平台,目前出來一個雛形,各位可以參考使用

連結:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk

Linux伺服器配置---ftp使用者黑名單

繼續閱讀