systems:media_server:secure_the_server
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
systems:media_server:secure_the_server [2025/05/30 19:39] – peter | systems:media_server:secure_the_server [2025/05/31 16:46] (current) – peter | ||
---|---|---|---|
Line 6: | Line 6: | ||
* [[Systems: | * [[Systems: | ||
+ | * [[Systems: | ||
+ | * [[Systems: | ||
---- | ---- | ||
- | ===== Install fail2ban ===== | + | * [[Systems: |
- | + | * [[Systems:Media Server: | |
- | ==== Update | + | * [[Systems:Media Server:Secure the Server:Harden Sudo|Harden Sudo]] |
- | + | | |
- | + | * [[Systems:Media Server:Secure | |
- | <code bash> | + | |
- | sudo apt update && sudo apt upgrade | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Install Fail2Ban ==== | + | |
- | + | ||
- | <code bash> | + | |
- | sudo apt install fail2ban | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Configure Fail2Ban ==== | + | |
- | + | ||
- | The default | + | |
- | + | ||
- | <WRAP important> | + | |
- | **WARNING:** The default values may change with package updates, so if you want to change | + | |
- | </ | + | |
- | + | ||
- | Here are salient lines from the default configuration: | + | |
- | + | ||
- | <file bash / | + | |
- | # line 87 : ignore your own local IP | + | |
- | #ignoreself = true | + | |
- | + | ||
- | # line 92 : possible to add ignored networks | + | |
- | #ignoreip = 127.0.0.1/ | + | |
- | + | ||
- | # line 101 : number of seconds that a host is banned | + | |
- | # - 1m ⇒ 1 minutes | + | |
- | # - 1h ⇒ 1 houer | + | |
- | # - 1d ⇒ 1 day | + | |
- | # - 1mo ⇒ 1 month | + | |
- | # - 1y ⇒ 1 year | + | |
- | bantime | + | |
- | + | ||
- | # line 105 : A host is banned if it has generated " | + | |
- | findtime | + | |
- | + | ||
- | # line 108 : " | + | |
- | maxretry = 5 | + | |
- | + | ||
- | # line 178 : destination email address if enabling email notification | + | |
- | destemail = root@localhost | + | |
- | + | ||
- | # line 181 : sender address if enabling email notification | + | |
- | sender = root@< | + | |
- | + | ||
- | # line 263 : default action | + | |
- | # - %(action_)s ⇒ ban only | + | |
- | # - %(action_mw)s ⇒ band and email notification (includes Whois info) | + | |
- | # - %(action_mwl)s ⇒ band and email notification (includes Whois info and logs) | + | |
- | action = %(action_)s | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Override | + | |
- | + | ||
- | As root, create | + | |
- | + | ||
- | <file bash /etc/fail2ban/ | + | |
- | [DEFAULT] | + | |
- | ignoreip = 127.0.0.1/8 ::1 | + | |
- | bantime | + | |
- | findtime | + | |
- | maxretry = 5 | + | |
- | destemail = root@localhost | + | |
- | sender = root@mediaserver | + | |
- | </file> | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Restart Fail2Ban ==== | + | |
- | + | ||
- | <code bash> | + | |
- | sudo systemctl restart fail2ban | + | |
- | </code> | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Verify Fail2Ban ==== | + | |
- | + | ||
- | <code bash> | + | |
- | sudo systemctl status fail2ban | + | |
- | </code> | + | |
- | + | ||
- | returns: | + | |
- | + | ||
- | < | + | |
- | fail2ban.service - Fail2Ban Service | + | |
- | | + | |
- | | + | |
- | Docs: man: | + | |
- | Main PID: 3108 (fail2ban-server) | + | |
- | Tasks: 5 (limit: 154383) | + | |
- | | + | |
- | CPU: 110ms | + | |
- | | + | |
- | | + | |
- | + | ||
- | May 30 19:38:01 mediaserver systemd[1]: Started fail2ban.service - Fail2Ban Service. | + | |
- | May 30 19:38:02 mediaserver fail2ban-server[3108]: 2025-05-30 19: | + | |
- | May 30 19:38:02 mediaserver fail2ban-server[3108]: Server ready | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + |
systems/media_server/secure_the_server.1748633996.txt.gz · Last modified: 2025/05/30 19:39 by peter