fail2ban保護vsftpd-server

因為工作需要,在公司內部需利用ftp上傳小工具或是檔案到NAT主機上面
所以NAT主機上面有開放vsftpd服務,因為是有時後才會用到,所以會手動
將服務啟動即停止,但是有時候忘記停止時,隔天查log就會有些無聊的網友
來測試連線ftp真是機車

所以想了個辦法就是利用之前fail2ban,好像也可以保護vsftpd,看了一下設定檔有

如下

[VSFTPD]
# Option: enabled
# Notes.: enable monitoring for this section.
# Values: [true | false] Default: false
#
enabled = false (只要將這一行改成 true即可)

# Option: logfile
# Notes.: logfile to monitor.
# Values: FILE Default: /var/log/secure
#
logfile = /var/log/vsftpd.log

# Option:  port
# Notes.:  specifies port to monitor
# Values:  [ NUM | STRING ]  Default:
#
port = ftp

# Option: timeregex
# Notes.: regex to match timestamp in VSFTPD logfile.
# Values: [Mar 7 17:53:28]
# Default: S{3}s{1,2}d{1,2} d{2}:d{2}:d{2}
#
timeregex = S{3}s{1,2}d{1,2} d{2}:d{2}:d{2}

# Option: timepattern
# Notes.: format used in “timeregex” fields definition. Note that ‘%’ must be
# escaped with ‘%’ (see http://rgruet.free.fr/PQR2.3.html#timeModule)
# Values: TEXT Default: %%b %%d %%H:%%M:%%S
#
timepattern = %%b %%d %%H:%%M:%%S

# Option: failregex
# Notes.: regex to match the password failures messages in the logfile.
# Values: TEXT Default: Authentication failure|Failed password|Invalid user
#
failregex = FAIL LOGIN

再來就是就是設定vsftpd的log
修改 /etc/vsftpd/vsftpd.conf
將#xferlog_file=/var/log/vsftpd.log 將#字號拿掉重新啟動vsftpd服務即可
因為之前的設定 maxfailures = 3 表示3次錯誤就封鎖,所以可以小小的保護一下ftp-server



本篇瀏覽人數: 2370
分類: Vsftp 相關。這篇內容的永久連結

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *