computers:ssh_security
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| computers:ssh_security [2011/09/08 14:03] – [Limit by IP address] chkuo | computers:ssh_security [2023/03/28 14:40] (current) – [Limit by IP address] chkuo | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| ===== Limit by IP address ===== | ===== Limit by IP address ===== | ||
| - | < | + | First: deny connection from all in '' |
| - | # /etc/hosts.allow | + | |
| - | # allow Academia Sinica IPs (140.109.) | + | |
| - | # allow intranet (10.0.1.*) | + | |
| - | sshd: 140.109., 192.168.1., 10.0.1. : allow | + | |
| - | </ | + | |
| < | < | ||
| # / | # / | ||
| Line 20: | Line 14: | ||
| sshd: ALL | sshd: ALL | ||
| </ | </ | ||
| + | |||
| + | Second: specify the allowed IPs in ''/ | ||
| + | < | ||
| + | # / | ||
| + | # allow intranet IPs (192.168.1.*) | ||
| + | # allow IPMB IPs (172.*.*.*) | ||
| + | # allow Academia Sinica IPs (140.109.*.*) | ||
| + | sshd: 192.168.1., 172., 140.109.: allow | ||
| + | </ | ||
| + | |||
| ===== Check log files ===== | ===== Check log files ===== | ||
| Line 25: | Line 29: | ||
| <code bash> | <code bash> | ||
| - | more /var/log/secure.log | + | grep sshd /var/log/system.log |
| </ | </ | ||
| Line 31: | Line 35: | ||
| <code bash> | <code bash> | ||
| - | more / | + | grep sshd / |
| </ | </ | ||
| + | ===== Fail2ban ===== | ||
| + | Install [[http:// | ||
| + | Ubuntu: | ||
| + | <code bash> | ||
| + | # install | ||
| + | sudo apt install fail2ban | ||
| + | # edit the conf file / | ||
| + | # for example, increase ' | ||
| + | # restart the service | ||
| + | sudo / | ||
| + | # regex test | ||
| + | sudo fail2ban-regex / | ||
| + | # check status | ||
| + | sudo / | ||
| + | # check client status | ||
| + | sudo fail2ban-client status | ||
| + | sudo fail2ban-client status sshd | ||
| + | # check log | ||
| + | cat / | ||
| + | # unban | ||
| + | sudo fail2ban-client set sshd unbanip xxx.xxx.xxx.xxx | ||
| + | </ | ||
| + | |||
| + | If registered at [[http:// | ||
| + | <code bash> | ||
| + | destemail = fail2ban@blocklist.de | ||
| + | sendermail = fail2ban@your-server.tld | ||
| + | </ | ||
computers/ssh_security.1315461828.txt.gz · Last modified: by chkuo