現在這個平台、blog 這陣子約 2~3 週常常被 alert CPU, memory 使用量過高
剛好最近工作很忙,沒時間查看一拖就是幾個週…
這幾天一查… 發現被 hack 植入挖礦程式
anyway 有很多該做的防範沒有處理
起手式 fail2ban 先裝起來
var/log/auth.log
sudo apt update
sudo apt install fail2ban
cp /etc/fail2ban/jail.{conf, local}
修改~
bantime = 10m
# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 3m
# "maxretry" is the number of failures before a host get banned.
maxretry = 5
進階
# 檢查
[sshd]
enabled = true
# 你的 ssh 對應 port
port = 50022
重啟服務
sudo service fail2ban stop
sudo service fail2ban start
sudo systemctl status fail2ban
也記得把 ssh port 從預設改掉~