Expand security status details
This commit is contained in:
@@ -19,10 +19,49 @@ def security() -> str:
|
|||||||
if not out or "ERROR:" in out:
|
if not out or "ERROR:" in out:
|
||||||
return "🔐 Security\n\n⚠️ permitrootlogin not found"
|
return "🔐 Security\n\n⚠️ permitrootlogin not found"
|
||||||
|
|
||||||
if "no" in out.lower():
|
lines = ["🔐 Security\n"]
|
||||||
return "🔐 Security\n\n🟢 Root login disabled"
|
|
||||||
|
|
||||||
return "🔐 Security\n\n🔴 Root login ENABLED"
|
if "no" in out.lower():
|
||||||
|
lines.append("🟢 Root login disabled")
|
||||||
|
else:
|
||||||
|
lines.append("🔴 Root login ENABLED")
|
||||||
|
|
||||||
|
pass_auth = _cmd("sshd -T | grep -i '^passwordauthentication'")
|
||||||
|
if pass_auth and "ERROR:" not in pass_auth:
|
||||||
|
lines.append("🔴 Password auth enabled" if "yes" in pass_auth.lower() else "🟢 Password auth disabled")
|
||||||
|
|
||||||
|
pubkey_auth = _cmd("sshd -T | grep -i '^pubkeyauthentication'")
|
||||||
|
if pubkey_auth and "ERROR:" not in pubkey_auth:
|
||||||
|
lines.append("🟢 Pubkey auth enabled" if "yes" in pubkey_auth.lower() else "🔴 Pubkey auth disabled")
|
||||||
|
|
||||||
|
sec_updates = _cmd("apt list --upgradable 2>/dev/null | grep -i security | wc -l")
|
||||||
|
if sec_updates and "ERROR:" not in sec_updates:
|
||||||
|
try:
|
||||||
|
count = int(sec_updates.strip())
|
||||||
|
lines.append(f"🔔 Security updates: {count}")
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
time_info = _cmd("timedatectl")
|
||||||
|
if time_info and "ERROR:" not in time_info:
|
||||||
|
tz = None
|
||||||
|
ntp = None
|
||||||
|
synced = None
|
||||||
|
for line in time_info.splitlines():
|
||||||
|
if "Time zone:" in line:
|
||||||
|
tz = line.split("Time zone:", 1)[1].strip()
|
||||||
|
if "NTP service:" in line:
|
||||||
|
ntp = line.split("NTP service:", 1)[1].strip()
|
||||||
|
if "System clock synchronized:" in line:
|
||||||
|
synced = line.split("System clock synchronized:", 1)[1].strip()
|
||||||
|
if tz:
|
||||||
|
lines.append(f"🕒 Time zone: {tz}")
|
||||||
|
if ntp:
|
||||||
|
lines.append(f"🔧 NTP service: {ntp}")
|
||||||
|
if synced:
|
||||||
|
lines.append(f"⏱ Clock synced: {synced}")
|
||||||
|
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
# ---------- DISKS ----------
|
# ---------- DISKS ----------
|
||||||
|
|||||||
Reference in New Issue
Block a user