{
 "fail2ban 自動封鎖暴力破解#1": {
  "type": "flow",
  "reveal": [
   1,
   2,
   2,
   3,
   5
  ],
  "nodes": [
   {
    "label": "外部攻擊"
   },
   {
    "label": "失敗登入",
    "sub": "admin 不存在帳號"
   },
   {
    "label": "寫入日誌"
   },
   {
    "label": "fail2ban",
    "sub": "讀取日誌"
   },
   {
    "label": "防火牆封鎖",
    "sub": "封鎖來源 IP",
    "kind": "end"
   }
  ]
 },
 "fail2ban 自動封鎖暴力破解#2": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "cards": [
   {
    "title": "filter",
    "points": [
     "正規表示式辨識失敗行",
     "抓出來源 IP"
    ]
   },
   {
    "title": "jail",
    "points": [
     "filter 套用在日誌檔",
     "定義封鎖規則"
    ]
   },
   {
    "title": "action",
    "points": [
     "預設呼叫防火牆",
     "加入封鎖規則"
    ]
   },
   {
    "title": "三個參數",
    "points": [
     "maxretry 失敗次數",
     "findtime 統計時間",
     "bantime 封鎖多久"
    ]
   }
  ]
 },
 "fail2ban 自動封鎖暴力破解#3": {
  "type": "table",
  "head": [
   "項目",
   "重點"
  ],
  "rows": [
   [
    "jail.local",
    "覆寫設定,不改 jail.conf"
   ],
   [
    "ignoreip",
    "白名單,避免封到自己"
   ],
   [
    "bantime = -1",
    "永久封鎖,不建議"
   ],
   [
    "backend = systemd",
    "日誌在 journal 時檢查"
   ]
  ],
  "reveal": [
   1,
   2,
   3,
   4
  ],
  "widths": [
   2,
   3
  ]
 },
 "fail2ban 自動封鎖暴力破解#4": {
  "type": "flow",
  "reveal": [
   0,
   1,
   2,
   3,
   4,
   5
  ],
  "nodes": [
   {
    "label": "安裝",
    "sub": "apt install"
   },
   {
    "label": "啟動",
    "sub": "enable --now"
   },
   {
    "label": "[DEFAULT]",
    "sub": "所有 jail 預設"
   },
   {
    "label": "bantime",
    "sub": "1h"
   },
   {
    "label": "findtime",
    "sub": "10m",
    "kind": "end"
   }
  ]
 },
 "fail2ban 自動封鎖暴力破解#5": {
  "type": "flow",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "nodes": [
   {
    "label": "maxretry",
    "sub": "5"
   },
   {
    "label": "ignoreip",
    "sub": "本機與內網網段"
   },
   {
    "label": "[sshd]",
    "sub": "SSH 專用"
   },
   {
    "label": "enabled",
    "sub": "true",
    "kind": "end"
   }
  ]
 },
 "fail2ban 自動封鎖暴力破解#6": {
  "type": "bar",
  "labels": [
   "預設",
   "SSH"
  ],
  "values": [
   1,
   24
  ],
  "unit": "小時",
  "reveal": [
   0,
   1,
   2,
   2
  ],
  "highlight": 1
 },
 "fail2ban 自動封鎖暴力破解#7": {
  "type": "table",
  "head": [
   "指令",
   "用途"
  ],
  "rows": [
   [
    "fail2ban-client status",
    "看有哪些 jail"
   ],
   [
    "fail2ban-client status sshd",
    "看被封鎖的 IP"
   ],
   [
    "set sshd unbanip IP",
    "手動解除封鎖"
   ],
   [
    "fail2ban-regex",
    "測試過濾規則"
   ]
  ],
  "reveal": [
   2,
   3,
   4
  ],
  "widths": [
   3,
   2
  ]
 },
 "系統更新與自動安全更新#1": {
  "type": "cards",
  "reveal": [
   0,
   1,
   3
  ],
  "cards": [
   {
    "title": "沒有更新",
    "points": [
     "多數入侵源自此",
     "公開修補程式未安裝"
    ]
   },
   {
    "title": "更新有風險",
    "points": [
     "可能改變行為",
     "造成故障"
    ]
   },
   {
    "title": "折衷做法",
    "points": [
     "安全更新自動化",
     "大版本手動規劃"
    ]
   }
  ]
 },
 "系統更新與自動安全更新#3": {
  "type": "flow",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "nodes": [
   {
    "label": "更新清單",
    "sub": "apt update"
   },
   {
    "label": "查可更新",
    "sub": "apt list"
   },
   {
    "label": "安裝更新",
    "sub": "apt upgrade"
   },
   {
    "label": "清相依",
    "sub": "apt autoremove",
    "kind": "end"
   }
  ]
 },
 "系統更新與自動安全更新#4": {
  "type": "flow",
  "reveal": [
   1,
   3
  ],
  "nodes": [
   {
    "label": "更新完成"
   },
   {
    "label": "檢查檔案",
    "sub": "reboot-required"
   },
   {
    "label": "需要重開機",
    "kind": "end"
   }
  ]
 },
 "系統更新與自動安全更新#5": {
  "type": "flow",
  "reveal": [
   2,
   3,
   4,
   5,
   6,
   6
  ],
  "nodes": [
   {
    "label": "安裝",
    "sub": "unattended-upgrades"
   },
   {
    "label": "設定精靈",
    "sub": "dpkg-reconfigure"
   },
   {
    "label": "產生設定檔",
    "sub": "20auto-upgrades"
   },
   {
    "label": "每日更新",
    "sub": "只裝安全更新"
   },
   {
    "label": "自動重開",
    "sub": "預設關閉"
   },
   {
    "label": "試跑",
    "sub": "--dry-run",
    "kind": "end"
   }
  ]
 },
 "系統更新與自動安全更新#6": {
  "type": "table",
  "head": [
   "項目",
   "內容"
  ],
  "rows": [
   [
    "安裝",
    "apt install unattended-upgrades"
   ],
   [
    "精靈",
    "dpkg-reconfigure"
   ],
   [
    "Update-Package-Lists \"1\"",
    "每天更新套件清單"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "widths": [
   3,
   3
  ]
 },
 "系統更新與自動安全更新#7": {
  "type": "table",
  "head": [
   "設定",
   "作用"
  ],
  "rows": [
   [
    "Unattended-Upgrade \"1\"",
    "每天自動升級"
   ],
   [
    "Mail",
    "更新或錯誤時寄信"
   ],
   [
    "Remove-Unused-Dependencies",
    "移除用不到的相依"
   ],
   [
    "Automatic-Reboot / Time",
    "是否重開與時間 04:00"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   4
  ],
  "widths": [
   3,
   3
  ]
 },
 "監控、日誌輪替與備份#1": {
  "type": "cards",
  "reveal": [
   0,
   4,
   4,
   4
  ],
  "cards": [
   {
    "title": "CPU",
    "points": [
     "負載平均與核心數比較",
     "長期超過就忙不過來"
    ]
   },
   {
    "title": "記憶體",
    "points": [
     "含 swap"
    ]
   },
   {
    "title": "磁碟空間",
    "points": [
     "超過 80% 要警覺",
     "100% 資料庫和日誌寫不進去"
    ]
   },
   {
    "title": "網路",
    "points": [
     "連線統計"
    ]
   }
  ]
 },
 "監控、日誌輪替與備份#2": {
  "type": "table",
  "head": [
   "指令",
   "看什麼"
  ],
  "rows": [
   [
    "uptime",
    "負載平均 1/5/15 分鐘"
   ],
   [
    "free -h",
    "記憶體與 swap"
   ],
   [
    "df -h",
    "各檔案系統使用量"
   ],
   [
    "du -sh /var/log/*",
    "最大的日誌資料夾"
   ],
   [
    "top / htop",
    "各程式 CPU 與記憶體"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4,
   5
  ],
  "widths": [
   2,
   3
  ]
 },
 "監控、日誌輪替與備份#4": {
  "type": "table",
  "head": [
   "系統",
   "SSH 登入日誌"
  ],
  "rows": [
   [
    "Ubuntu",
    "/var/log/auth.log"
   ],
   [
    "RHEL 系",
    "/var/log/secure"
   ]
  ],
  "reveal": [
   0,
   2
  ],
  "widths": [
   1,
   2
  ]
 },
 "監控、日誌輪替與備份#5": {
  "type": "table",
  "head": [
   "指令",
   "用途"
  ],
  "rows": [
   [
    "journalctl -u nginx --since",
    "nginx 最近一小時"
   ],
   [
    "journalctl -p err -b",
    "開機後的錯誤日誌"
   ],
   [
    "journalctl -f",
    "即時追蹤"
   ],
   [
    "systemctl --failed",
    "列出失敗的服務"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "widths": [
   3,
   2
  ]
 },
 "監控、日誌輪替與備份#6": {
  "type": "table",
  "head": [
   "指令",
   "用途"
  ],
  "rows": [
   [
    "last -n 10",
    "最近 10 筆登入"
   ],
   [
    "sudo lastb | head",
    "失敗登入(需 root)"
   ],
   [
    "tail -f error.log",
    "即時看 nginx 錯誤"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "widths": [
   2,
   2
  ]
 },
 "監控、日誌輪替與備份#7": {
  "type": "flow",
  "reveal": [
   1,
   3,
   4,
   4,
   5
  ],
  "nodes": [
   {
    "label": "日誌持續寫入"
   },
   {
    "label": "logrotate",
    "sub": "定期輪替"
   },
   {
    "label": "壓縮、刪除舊檔",
    "sub": "rotate 12"
   },
   {
    "label": "postrotate",
    "sub": "通知 nginx"
   },
   {
    "label": "測試",
    "sub": "logrotate -d",
    "kind": "end"
   }
  ]
 }
}