Compare commits

..

116 Commits

Author SHA1 Message Date
PapaTramp b0abf99d1b feat: suppress sac-fail.count on shutdown (2.3.2-SAC)
Phase 4.2: SAC_SUPPRESS_FAIL_COUNT during lifecycle shutdown so restart during SAC deploy does not trip Telegram fallback. Add docs/sac-ingest.ru.md for SAC_TIMEOUT_SEC guidance, smoke test, and release manifest.
2026-07-08 14:12:25 +10:00
PapaTramp 05733d7402 fix: WHITELIST_IPS validation and CSV load (2.3.1-SAC)
Parse whitelist from config via peek; validate IPv4 octets with BASH_REMATCH and 10# arithmetic.
2026-07-08 13:03:40 +10:00
PapaTramp 18a65078fc feat: safe config parser without source (2.3.0-SAC)
Whitelist-based /etc/ssh-monitor.conf load; validate URLs/enums/CIDR; remove BACKUP_WEBHOOK_URL.
2026-07-08 12:57:36 +10:00
PapaTramp 6511d34ca7 fix: suppress sudo Telegram during SAC agent update (2.2.3-SAC)
Whitelist SAC maintenance commands in ssh-monitor-perms and monitor_sudo; pre-commit uses working python on Windows.
2026-07-08 12:25:06 +10:00
PapaTramp 440577ac5a chore: install-git-hooks.ps1 for Windows 2026-07-08 12:14:11 +10:00
PapaTramp 5ac4792c3c chore: auto manifest on version bump; local manual script only
contrib/manifest/generate.py + pre-commit hook; install-git-hooks.sh creates
.local/build-release-manifest.sh (gitignored). Remove scripts/ from remote.
2026-07-08 12:05:21 +10:00
PapaTramp 0399a6d384 fix: manifest SHA256 from git blobs (CRLF/LF) — release 2.2.2-SAC
Manifest was hashed from Windows working tree while Linux checkout uses
git blobs; verify failed with sha256 mismatch. build-release-manifest.sh
now hashes :index/HEAD; .gitattributes enforces LF for agent scripts.
2026-07-08 12:00:51 +10:00
PapaTramp 6df83f1838 feat: release 2.2.1-SAC — phase 2 manifest verify and quiet SAC updates
Pinned GIT_REF/verify, release manifest, no blind reset --hard; suppress
lifecycle and watchdog Telegram during updater; healthcheck via json.dumps.
2026-07-08 11:48:34 +10:00
PapaTramp 275d305d62 feat: watchdog Telegram shows server name (2.1.9-SAC)
Add shared server label helpers in ssh-monitor-perms.sh; roadmap marks
phase 1 done and phase 2.2.0 as next release.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 11:28:57 +10:00
PapaTramp 2048162057 feat: release 2.1.8-SAC — security phase 1 and SAC-first update hardening
Updater applies chmod/chown on config, spool and state paths on every run.
SAC is the primary update path; optional cron uses the same behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 09:44:24 +10:00
PapaTramp ec0857b8f2 docs: security roadmap по аудиту (фазы 1–4, чек-лист) 2026-07-07 20:57:45 +10:00
PapaTramp 732f32559a fix: harden push-github-snapshot URL rewrite and README header 2026-07-07 20:28:59 +10:00
PapaTramp 141a841f6f docs: sync README version 2.1.6-SAC; add push-github-snapshot.sh 2026-07-07 20:27:44 +10:00
PapaTramp 9e756674d0 fix: daily report без локального Telegram при fallback SAC (2.1.6-SAC)
Суточные report.daily.* уходят только в SAC/spool; SAC_TIMEOUT_SEC=45;
приоритет report.* в sac_flush_spool, до 50 файлов за цикл.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 12:00:35 +10:00
PapaTramp 0a80effd77 docs: sync README version with version.txt 2.1.5-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 14:14:43 +10:00
PapaTramp de61c6c771 fix: daily report active users count matches who sessions (2.1.5-SAC)
Include local/console who lines; active_count from session list not raw who line count.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 14:41:52 +10:00
PapaTramp c96e870542 feat: enrich SAC events with session_id, tty and source_ip (2.1.4-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-22 10:13:40 +10:00
PapaTramp 489d071208 feat(deploy): sync SERVER_IPV4 hint and DAILY_REPORT_ENABLED on update (2.1.3-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-22 10:01:16 +10:00
PapaTramp 1361fd264c feat: merge missing SAC keys into config on deploy (2.1.2-SAC)
Append absent SAC variables from example instead of overwriting ssh-monitor.conf; set UseSAC=fallback on install and update.
2026-06-21 12:20:33 +10:00
PapaTramp 65da13363d docs: 2.1.1-SAC README and SAC REPO_URL override
Описано, что SSH-обновление из SAC передаёт REPO_URL/GIT_BRANCH из настроек агентов.
2026-06-20 20:03:58 +10:00
PapaTramp 31fcc4a8a7 merge: kalinamall main with 2.1.1-SAC updater git fix 2026-06-20 19:29:05 +10:00
PapaTramp 2ff60280ef fix: default updater git to kalinamall and honor REPO_URL from SAC (2.1.1-SAC)
Always sync kalinamall remote from REPO_URL; support GIT_BRANCH env for SAC-driven updates.
2026-06-20 19:28:14 +10:00
PapaTramp 9118bbdd64 chore: add .cursorignore to gitignore 2026-06-20 19:20:34 +10:00
PapaTramp cdb74393aa docs: concise README with SAC integration and version 2.1.0-SAC 2026-06-20 19:20:34 +10:00
PapaTramp b6d9901f05 chore: bump version to 2.1.0-SAC 2026-06-20 19:20:34 +10:00
PapaTramp 76fc865d22 chore: add .cursorignore to gitignore 2026-06-20 19:07:52 +10:00
PapaTramp bffc7f3245 docs: concise README with SAC integration and version 2.1.0-SAC 2026-06-20 19:02:59 +10:00
PapaTramp 9b454c3270 chore: bump version to 2.1.0-SAC 2026-06-19 23:42:12 +10:00
PapaTramp 619cc9e1ac chore(github): remove kalinamall/papatramp mirror scripts
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 11:57:03 +10:00
PapaTramp 577db1da47 chore(docs): sync repository URLs for kalinamall mirror 2026-06-16 11:37:52 +10:00
PapaTramp 2956d14d94 chore(docs): GitHub repo URLs, remove .cursor from git, mirror scripts
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 11:36:51 +10:00
PapaTramp 9a3855bf0a feat: deploy дописывает HEARTBEAT_INTERVAL при отсутствии в конфиге (2.0.6-SAC)
Явная проверка ключей в /etc/ssh-monitor.conf, блок 240 мин + watchdog; исправлен текст startup heartbeat.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 16:46:41 +10:00
PapaTramp 4cd1a85b3e feat: send agent.heartbeat on service startup (2.0.5-SAC)
After agent.lifecycle on boot, send heartbeat so SAC marks host online until next interval.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 11:51:16 +10:00
PapaTramp 42af3b1ae6 fix: sync heartbeat interval on every deploy run
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-11 09:26:03 +10:00
PapaTramp 7e5cad0231 feat: install ssh-monitor-watchdog on agent update (2.0.4-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 17:41:47 +10:00
PapaTramp e576671580 chore: bump release to 2.0.3-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 17:38:56 +10:00
PapaTramp 908f8958a4 feat: heartbeat 4h via HEARTBEAT_INTERVAL_MINUTES (2.0.2-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 17:25:19 +10:00
PapaTramp 59ba8cf811 chore: sync Cursor rules from CursorRules (version bump RDP/SSH split)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 09:31:56 +10:00
PapaTramp 84b8dab561 chore: add Cursor rule to bump SSH_MONITOR_VERSION and version.txt on script changes
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 09:29:23 +10:00
PapaTramp 2bed9516ec chore: bump release to 2.0.1-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 09:17:28 +10:00
PapaTramp 3d0876bb0b feat: deploy UseSAC fallback by default on install and script upgrade
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-03 09:15:22 +10:00
PapaTramp df77d8763f chore: bump release to 2.0.0-SAC
Major version line for NETLOGON deploy upgrades from 1.x agents.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 09:05:52 +10:00
PapaTramp 79f5b664b2 feat: lifecycle notification_body and aligned host label 1.2.13-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 18:11:28 +10:00
PapaTramp cf4e3b2e90 feat: lifecycle telegram_via routing and lifecycle details 1.2.12-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 12:26:14 +10:00
PapaTramp e1a37b8f89 feat: notification source line in agent alerts (1.2.11-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 11:52:42 +10:00
PapaTramp 70652bc6cb feat: Agent version line in daily SSH report (1.2.10-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 11:28:30 +10:00
PapaTramp 192713d2da chore: release 1.2.9-SAC (align version.txt and SSH_MONITOR_VERSION)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-31 11:18:58 +10:00
PapaTramp 454a220890 fix: daily report HTML line breaks without double spacing
Use single <br> in report_html and document DAILY_REPORT_ENABLED toggle.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 09:52:09 +10:00
PapaTramp 3820687310 feat: unify daily SSH report format with SAC; DAILY_REPORT_ENABLED toggle
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 17:17:59 +10:00
PapaTramp eceac58a60 feat: include host.ipv4 in SAC payload and release 1.2.7-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 13:33:40 +10:00
PapaTramp 3e1199e2ec chore: align ssh monitor and SAC module version 1.2.6-SAC
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 13:01:51 +10:00
PapaTramp 8c542624eb feat: SERVER_DISPLAY_NAME в SAC host.display_name (sac-client 1.2.6-SAC)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 11:49:23 +10:00
PapaTramp f06fbae8ee fix: update_ssh_monitor fetch+reset after kalinamall force-push
Release 1.2.5-SAC; prefer kalinamall remote; ff-only or hard reset.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 09:40:13 +10:00
PapaTramp fe2a38857b chore: release 1.2.4-SAC — SAC ingest HTTP 201/409/202
Bump SSH_MONITOR_VERSION; sac-client release tag; updater logs sac-client ver.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-28 09:34:19 +10:00
PapaTramp 0e83d8825d fix: accept SAC ingest HTTP 201, 409, and legacy 202 2026-05-28 09:13:13 +10:00
PapaTramp 31c4265716 fix: log_action to stderr so captured paths stay valid
find_remote_ssh_monitor_path output was polluted by log_action on stdout,
breaking -f checks; mirror user messages to stderr instead.
2026-05-28 08:24:09 +10:00
PapaTramp 731c50b0bc fix: find ssh-monitor in clone via git checkout and broader search
Restore ssh-monitor from HEAD when missing on disk; try git ls-files and
find fallback; log clone root listing on failure.
2026-05-28 08:20:37 +10:00
PapaTramp 7f4d25b91c fix: sync /opt/scripts/update_ssh_monitor.sh from git clone each run
After git pull, copy updater from clone to DEPLOY_INSTALL_PATH and re-exec
once so cron always picks up new logging without manual cp.
2026-05-28 08:15:51 +10:00
PapaTramp f3b7c9d41c feat: verbose update_ssh_monitor action log and run summary
Log each step to /var/log/update_script.log and stdout (unless --quiet).
End-of-run summary explains skip reasons: checksum match, git pull fail,
missing clone path, versions and sha256 prefixes.
2026-05-28 08:13:24 +10:00
PapaTramp d179b360f2 fix: heartbeat only to SAC, never Telegram/email
agent.heartbeat bypasses NOTIFY_CHAIN in all UseSAC modes; SAC ingest only.
Bump to 1.2.3-SAC.
2026-05-28 07:56:18 +10:00
PapaTramp dd980f0ba6 chore: bump release to 1.2.2-SAC
Increase SSH monitor release version used by sac-client payloads and refresh
RU/EN README references to the new version.
2026-05-27 15:53:29 +10:00
PapaTramp 746a8f8f76 feat: bootstrap SAC config on update from pre-SAC installs
ssh-monitor.conf.example ships dual SAC + Telegram defaults; updater
overwrites /etc/ssh-monitor.conf when UseSAC is off or SAC_API_KEY empty
or sac-client.sh is missing, with backup. Leaves configured hosts untouched.
2026-05-27 15:23:35 +10:00
PapaTramp 49ea1d2a7d chore: bump version to 1.2.1-SAC 2026-05-27 14:44:03 +10:00
PapaTramp 29c91ee0db feat: send full daily report body and stats in SAC details 2026-05-27 14:15:13 +10:00
PapaTramp 8627fdbcec chore: bump agent version to 1.2.0-SAC 2026-05-27 14:09:35 +10:00
PapaTramp a4ea24c3f1 feat: SAC fallback failure counter (2.3)
After SAC_FALLBACK_FAILURES consecutive POST errors, skip SAC until
/health recovers; persist count in SAC_FAIL_COUNT_FILE.
2026-05-27 13:36:19 +10:00
PapaTramp 3a1c9655ca feat: exclusive pilot — spool flush and verify script
Replay spool on each monitor loop; sac_post_payload refactor;
pilot-verify-exclusive.sh and --check-sac hints for exclusive mode.
2026-05-27 13:25:47 +10:00
PapaTramp f1c4adcc13 feat: first deploy via update_ssh_monitor.sh --deploy
Add first_deploy.sh wrapper and --deploy mode: git clone, install
ssh-monitor and sac-client, optional config/systemd/updater copy,
console summary and config variable checklist.
2026-05-27 12:36:02 +10:00
PapaTramp 1928e68088 fix: POST ingest to /api/v1/events when SAC_URL is host root
Health already used sac_base_url(); ingest used raw SAC_URL and got
HTTP 405 when config had only https://host without /api/v1/events.
2026-05-27 12:22:10 +10:00
PapaTramp 4cb158f30a fix: always sync sac-client.sh in update_ssh_monitor
Copy sac-client.sh on every git pull by checksum, not only when
ssh-monitor binary changes. Restart service when either file updates.
2026-05-27 12:20:14 +10:00
PapaTramp 18562af07a feat: map security events to SAC typed payloads 2026-05-27 11:24:19 +10:00
PapaTramp 52654e2735 feat: sudo и notify_send шлют события в SAC (dual) 2026-05-27 11:01:47 +10:00
PapaTramp a58027ed9b fix: update_ssh_monitor копирует sac-client.sh, REPO kalinamall 2026-05-27 10:47:38 +10:00
PapaTramp ce48008738 merge: kalinamall main + UseSAC sac-client 2026-05-27 10:40:03 +10:00
PapaTramp dd971d80bc feat: UseSAC sac-client.sh and --check-sac 2026-05-26 21:46:35 +10:00
PapaTramp 2c65edf7db sync: align internal repo with 1.1.3-server-label
- REPO_URL points to git.kalinamall.ru

- ssh-monitor.conf may be committed here (secrets); .env still ignored

- Docs note for closed vs public GitHub
2026-05-26 19:34:01 +10:00
PapaTramp 44f8eb6103 chore: ignore production config files with secrets
ssh-monitor.conf and local overrides must not be committed to public GitHub.
2026-05-26 19:33:39 +10:00
PapaTramp b801cf2385 feat: подпись сервера во всех уведомлениях и документация
Добавлены message_ensure_server_line и SERVER_DISPLAY_NAME; версия 1.1.3-server-label.
Гайды по уведомлениям и автообновлению.
2026-05-25 09:23:32 +10:00
PapaTramp e2c0d5cbc7 Update update_ssh_monitor.sh 2026-05-14 12:59:12 +10:00
PapaTramp 3d20498515 Create update_ssh_monitor.sh
Скрипт проверки наличия обновлений основного скрипта
2026-05-14 12:57:55 +10:00
PapaTramp 48d5a0aeba Remove rutube artifacts from repo; ignore local downloader files 2026-05-03 19:51:00 +10:00
PapaTramp cde5b8c135 Add rutube-download helper and yt-dlp archive id list 2026-05-03 19:48:28 +10:00
PapaTramp 654822304e docs: English readme, MIT license, README cleanup
- Add readme_eng.md (parallel to README.md)
- Add LICENSE (MIT)
- Refresh README (version, repo table, license section)
2026-05-03 19:44:45 +10:00
ssh-monitor 2cf6c145ab Add ENABLE_IP_BAN mode switch
Introduce ENABLE_IP_BAN in config and script.
When set to 0, ssh-monitor works in monitor-only mode (alerts without ipset/iptables bans).
2026-04-16 12:13:27 +10:00
ssh-monitor b5b37b7e84 Переход автобана на ipset, документация и правки README
- ssh-monitor: баны через ipset (hash:ip timeout), одно правило iptables/ip6tables;
  нормализация бан-листа (один IP — одна строка), версия 1.1.1-ipset.
- docs/install-prerequisites.ru.md: зависимости и установка пакетов (в т.ч. ipset).
- README: ссылка на docs, установка скрипта/systemd без дублирования apt; пометка про ipset.
- IPSET-NOTES.txt: заметки по развёртыванию ipset.
- ssh-monitor.conf.example: закомментированные переменные IPSET_*.
2026-04-16 11:30:04 +10:00
ssh-monitor 074032b761 README: абзац с ключевыми темами для поиска на GitHub. 2026-04-14 14:16:08 +10:00
ssh-monitor 85730bafb0 Версия 1.0.0: релиз, Makefile (make dist), README и .gitignore для архива. 2026-04-14 13:52:26 +10:00
ssh-monitor e273c995a5 Удалена интеграция Zabbix; остались Telegram и email (SMTP). 2026-04-14 12:20:04 +10:00
ssh-monitor 5f9abc5e4c Zabbix: передать ZABBIX_SERVER/HOST_NAME в окружение python3 для trapper 2026-04-14 11:47:25 +10:00
ssh-monitor 6ff93d9552 Zabbix: короткий plain для канала; seq в файле; alert через python3 -o 2026-04-14 11:41:03 +10:00
ssh-monitor 7d8cb00689 Zabbix: усечение UTF-8 для trapper Character (ZABBIX_ALERT_MAX_BYTES) 2026-04-14 11:29:45 +10:00
ssh-monitor c83b4f19d1 Zabbix alert: убрать NUL из текста перед trapper (-i) 2026-04-14 11:15:19 +10:00
ssh-monitor 54e90672c8 Zabbix: успех только по failed:0 в ответе; seq через -k/-o; подсказка при отказе сервера 2026-04-14 11:10:30 +10:00
ssh-monitor 7e83dc6a83 Zabbix: логировать stdout+stderr zabbix_sender; успех при failed: 0 в ответе 2026-04-14 11:06:11 +10:00
ssh-monitor 190add949d Zabbix: два вызова zabbix_sender (alert и seq), лог stderr при ошибке 2026-04-14 10:57:32 +10:00
ssh-monitor 27219355c2 fix(notify): отправка во все каналы NOTIFY_ORDER, не только первый успех
- BACKUP_WEBHOOK только если все каналы неуспешны

- README/conf.example; версия 0.9.5.3
2026-04-14 10:50:38 +10:00
ssh-monitor 98f63e77ad fix: локальное время в уведомлениях (NOTIFY_TZ) и антидубль Accepted
- notification_date: NOTIFY_TZ → DAILY_REPORT_TZ → date процесса

- SSH_ACCEPT_NOTIFY_DEDUP_SEC: пауза между Telegram для той же пары user+IP

- версия 0.9.5.2, README и conf.example
2026-04-14 10:23:58 +10:00
ssh-monitor fa3d415fd9 chore: версия 0.9.5.1 2026-04-14 10:14:22 +10:00
ssh-monitor 06c8fe2e8e fix: дубли SSH (journal + Accepted) и logind при Service=sshd
- journalctl: _COMM=sshd, fallback sshd/ssh; sort -u

- dedupe Accepted в одном проходе по user|ip|port

- LOGIND_SKIP_REMOTE: Type=ssh или Service=*sshd*, повторы loginctl
2026-04-14 10:12:40 +10:00
ssh-monitor 95ff57bc4d feat: строка «Сервер» с основным IPv4 в старте/стопе, отчёте и heartbeat 2026-04-14 10:08:29 +10:00
ssh-monitor 79233f52f7 fix: версия в Telegram при старте сразу под заголовком 2026-04-14 10:06:02 +10:00
ssh-monitor e9c98d4647 docs: обязательный NOTIFY_CHAIN в README и ssh-monitor.conf.example 2026-04-14 09:56:18 +10:00
ssh-monitor a3bd7ed9ad fix: выход с ошибкой, если нет ни одного канала NOTIFY_CHAIN 2026-04-14 09:55:03 +10:00
ssh-monitor a90efd3ed8 docs: Zabbix и пояснение ZABBIX_SEQ_KEY в README 2026-04-14 09:52:07 +10:00
ssh-monitor 36dddb35d6 feat(notify): каскад telegram → zabbix → email, NOTIFY_ORDER, SMTP, v0.9.5 2026-04-14 09:44:43 +10:00
PapaTramp 85c18be12e chore: зафиксировать линию версий 0.9 (semver 0.9.0)
- Комментарий в скрипте и уточнение в README
2026-04-14 08:11:49 +10:00
PapaTramp f9e033777e feat: версия 0.9.0, --version и вывод в лог/health/старт
- SSH_MONITOR_VERSION + суффикс +git[-dirty] при запуске из репозитория

- README: раздел про версионирование
2026-04-14 08:05:50 +10:00
PapaTramp 256e1c2430 feat(heartbeat): строка сервера с основным IPv4 в скобках 2026-04-14 07:59:52 +10:00
PapaTramp 938f5d76ee fix(logind): не дублировать SSH при Type=tty и Service=sshd
- LOGIND_SKIP_REMOTE: учёт Service=sshd, короткие повторы loginctl при гонке

- README и пример конфига
2026-04-13 12:28:00 +10:00
PapaTramp 4cae3da108 feat: единая инициализация меток LAST_* для SSH/sudo/logind
- checkpoint_stamp_init_if_bad: нет файла / битое значение → только метка «сейчас», без бэклога

- sudo/logind: убрано окно -30m при «первом» запуске (как у SSH)

- README: раздел про файлы-метки и отличие LAST_SECURITY_EVENTS_FILE
2026-04-13 10:06:57 +10:00
Луценко Андрей Анатольевич 9b453657d2 feat: мониторинг systemd-logind (journalctl), конфиг и антидубль SSH
- Опрос journalctl -u systemd-logind, LAST_LOGIND_CHECK_FILE, LOGIND_*

- README: параметры logind, ротация LAST_*, journalctl
2026-04-13 09:45:41 +10:00
PapaTramp 1d37905f27 feat: DAILY_REPORT_TZ for local-time daily report 2026-04-12 20:22:25 +10:00
PapaTramp f085fecd3a fix: sudo monitoring via journal grep and secure log 2026-04-12 20:16:53 +10:00
PapaTramp 2b205b56d9 fix: dedupe shutdown notify on TERM+EXIT trap 2026-04-12 20:06:55 +10:00
PapaTramp 75f1a1c841 fix: Telegram newlines instead of literal %0A 2026-04-12 20:03:25 +10:00
PapaTramp e93fde7f52 feat: reliability, ops hooks, security checks, daily report 2026-04-12 19:30:32 +10:00
9 changed files with 16 additions and 16 deletions
+4 -4
View File
@@ -1,10 +1,10 @@
# ssh-monitor
# ssh-monitor
**Версия:** `2.3.0-SAC`
Bash-мониторинг **SSH**, **sudo**, **systemd-logind**: Telegram/email, бан IP (ipset), ежедневный отчёт, heartbeat.
**Security Alert Center:** модуль **`sac-client.sh`**, режим `UseSAC` (`off` | `exclusive` | `dual` | `fallback`) — [контракт SAC](https://git.papatramp.ru/PapaTramp/security-alert-center/src/branch/main/docs/agent-integration.md). Ingest / таймауты / fallback: [docs/sac-ingest.ru.md](docs/sac-ingest.ru.md). **Основной способ обновления на Linux** — кнопка **«Обновить ssh-monitor (SSH)»** в SAC: сервер передаёт `REPO_URL` / `GIT_BRANCH`, updater сам подтягивает git, выставляет права на конфиг/spool/state и перезапускает сервис. Cron/systemd timer — опционально.
**Security Alert Center:** модуль **`sac-client.sh`**, режим `UseSAC` (`off` | `exclusive` | `dual` | `fallback`) — [контракт SAC](https://git.kalinamall.ru/PapaTramp/security-alert-center/src/branch/main/docs/agent-integration.md). Ingest / таймауты / fallback: [docs/sac-ingest.ru.md](docs/sac-ingest.ru.md). **Основной способ обновления на Linux** — кнопка **«Обновить ssh-monitor (SSH)»** в SAC: сервер передаёт `REPO_URL` / `GIT_BRANCH`, updater сам подтягивает git, выставляет права на конфиг/spool/state и перезапускает сервис. Cron/systemd timer — опционально.
**Безопасность (2.1.7+):** агент работает от root; доверяйте только своему git-зеркалу (`REPO_URL`) и `/etc/ssh-monitor.conf` (`chmod 600`). С **2.3.0** конфиг читается **без `source`** (whitelist ключей, без выполнения bash из файла). Updater дописывает обязательные ключи и **на каждом прогоне** применяет `chmod`/`chown` к конфигу, SAC-spool и state-файлам. Подробнее: [docs/security-roadmap.ru.md](docs/security-roadmap.ru.md).
@@ -20,7 +20,7 @@ Bash-мониторинг **SSH**, **sudo**, **systemd-logind**: Telegram/email,
## Конфигурация
> **Закрытый инстанс Gitea:** в доверенном закрытом репозитории допустимо хранить **`ssh-monitor.conf`** с боевыми токенами (файл не в `.gitignore`). В публичном [GitHub](https://git.papatramp.ru/PapaTramp/ssh-monitor) такой файл игнорируется — используйте только `ssh-monitor.conf.example`.
> **Закрытый инстанс Gitea:** в доверенном закрытом репозитории допустимо хранить **`ssh-monitor.conf`** с боевыми токенами (файл не в `.gitignore`). В публичном [GitHub](https://git.kalinamall.ru/PapaTramp/ssh-monitor) такой файл игнорируется — используйте только `ssh-monitor.conf.example`.
Скрипт читает параметры из `/etc/ssh-monitor.conf` в формате `KEY="value"` (парсер с whitelist ключей; произвольный bash в файле не выполняется).
@@ -171,7 +171,7 @@ bash -n ./ssh-monitor
make dist
```
Появится файл `ssh-monitor-<версия>.tar.gz` (через `git archive`). Готовые архивы для установки без клона репозитория прикладываются к [релизам на GitHub](https://git.papatramp.ru/PapaTramp/ssh-monitor/releases).
Появится файл `ssh-monitor-<версия>.tar.gz` (через `git archive`). Готовые архивы для установки без клона репозитория прикладываются к [релизам на GitHub](https://git.kalinamall.ru/PapaTramp/ssh-monitor/releases).
## Установка скрипта, конфигурации и systemd
+5 -5
View File
@@ -104,7 +104,7 @@ git tag 2.2.3-SAC
**SAC / env на хосте** (через настройки SAC или unit):
```bash
REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git
REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git
GIT_REF=2.2.0-SAC
GIT_VERIFY_MODE=tag
```
@@ -114,7 +114,7 @@ GIT_VERIFY_MODE=tag
```ini
[Service]
Type=oneshot
Environment=REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git
Environment=REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git
Environment=GIT_REF=2.2.0-SAC
Environment=GIT_VERIFY_MODE=tag
ExecStart=/opt/scripts/update_ssh_monitor.sh
@@ -125,7 +125,7 @@ ExecStart=/opt/scripts/update_ssh_monitor.sh
## Первичная установка (--deploy)
```bash
sudo REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git ./update_ssh_monitor.sh --deploy
sudo REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git ./update_ssh_monitor.sh --deploy
# или first_deploy.sh с REPO_URL в окружении
```
@@ -142,7 +142,7 @@ sudo chmod 750 /opt/scripts/update_ssh_monitor.sh
Проверка:
```bash
sudo REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
sudo REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
sudo tail -30 /var/log/update_script.log
```
@@ -151,7 +151,7 @@ sudo tail -30 /var/log/update_script.log
### Cron
```
0 4 * * * REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
0 4 * * * REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
```
### systemd timer
+1 -1
View File
@@ -2,7 +2,7 @@
Документ для эксплуатации **ssh-monitor** с `UseSAC=fallback` или `exclusive` при нагрузке на SAC (массовый update агентов, deploy backend).
См. также: [ingest-mass-update-backlog.ru.md](https://git.papatramp.ru/PapaTramp/security-alert-center/src/branch/main/docs/ingest-mass-update-backlog.ru.md) (SAC + ops).
См. также: [ingest-mass-update-backlog.ru.md](https://git.kalinamall.ru/PapaTramp/security-alert-center/src/branch/main/docs/ingest-mass-update-backlog.ru.md) (SAC + ops).
## `SAC_TIMEOUT_SEC`
+2 -2
View File
@@ -1,4 +1,4 @@
# Security roadmap — ssh-monitor
# Security roadmap — ssh-monitor
Чек-лист правок по аудиту безопасности. **Код пока не трогаем** — документ для совместного просмотра и утверждения фаз.
@@ -35,7 +35,7 @@
Bump: `ssh-monitor` (`SSH_MONITOR_VERSION`) + `version.txt` в каждом релизе.
**Текущий статус (2026-07-08):** фаза **4.2** закрыта (2.3.2-SAC). Дальше — ops (`UseSAC=exclusive`, пачки update) и опционально GPG / `GIT_REF=tag` на проде.
Backlog по ingest при массовом update (SAC + ops): [ingest-mass-update-backlog.ru.md](https://git.papatramp.ru/PapaTramp/security-alert-center/src/branch/main/docs/ingest-mass-update-backlog.ru.md) (отдельный ToDo).
Backlog по ingest при массовом update (SAC + ops): [ingest-mass-update-backlog.ru.md](https://git.kalinamall.ru/PapaTramp/security-alert-center/src/branch/main/docs/ingest-mass-update-backlog.ru.md) (отдельный ToDo).
---
Regular → Executable
View File
+1 -1
View File
@@ -160,7 +160,7 @@ Version is set as **`SSH_MONITOR_VERSION`** in **`ssh-monitor`** and **`version.
make dist
```
Produces `ssh-monitor-<version>.tar.gz` (via `git archive`). Prebuilt archives are attached to [GitHub releases](https://git.papatramp.ru/PapaTramp/ssh-monitor/releases).
Produces `ssh-monitor-<version>.tar.gz` (via `git archive`). Prebuilt archives are attached to [GitHub releases](https://git.kalinamall.ru/PapaTramp/ssh-monitor/releases).
## Installing the script, config, and systemd
View File
Regular → Executable
+2 -2
View File
@@ -77,7 +77,7 @@ MAIL_SMTP_STARTTLS="1"
MAIL_SMTP_SSL="0"
# Auto-update script default (override on your server)
# REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git
# REPO_URL=https://github.com/PTah/ssh-monitor.git
EOF
if [[ -f "$WORK/README.md" ]]; then
@@ -99,7 +99,7 @@ if header in text and "Bash monitor for" not in text.split("**Версия:**",
Bash monitor for **SSH**, **sudo**, and **systemd-logind** on Linux: Telegram/SMTP alerts, optional IP ban (ipset/iptables), daily report, SAC integration.
**Repository:** https://git.papatramp.ru/PapaTramp/ssh-monitor
**Repository:** https://github.com/PTah/ssh-monitor
# ssh-monitor
Regular → Executable
+1 -1
View File
@@ -96,7 +96,7 @@ require_repo_url() {
if [ -n "${REPO_URL:-}" ]; then
return 0
fi
local msg="ERROR: REPO_URL не задан. Задайте export REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git или Environment=REPO_URL=... в systemd unit / cron."
local msg="ERROR: REPO_URL не задан. Задайте export REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git или Environment=REPO_URL=... в systemd unit / cron."
echo "$msg" >&2
mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null || true
echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: REPO_URL не задан" >>"$LOG_FILE" 2>/dev/null || true