Compare commits
1 Commits
b0abf99d1b
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 10704e0f88 |
@@ -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.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 — опционально.
|
||||
**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 — опционально.
|
||||
|
||||
**Безопасность (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.kalinamall.ru/PapaTramp/ssh-monitor) такой файл игнорируется — используйте только `ssh-monitor.conf.example`.
|
||||
> **Закрытый инстанс Gitea:** в доверенном закрытом репозитории допустимо хранить **`ssh-monitor.conf`** с боевыми токенами (файл не в `.gitignore`). В публичном [GitHub](https://git.papatramp.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.kalinamall.ru/PapaTramp/ssh-monitor/releases).
|
||||
Появится файл `ssh-monitor-<версия>.tar.gz` (через `git archive`). Готовые архивы для установки без клона репозитория прикладываются к [релизам на GitHub](https://git.papatramp.ru/PapaTramp/ssh-monitor/releases).
|
||||
|
||||
## Установка скрипта, конфигурации и systemd
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ git tag 2.2.3-SAC
|
||||
**SAC / env на хосте** (через настройки SAC или unit):
|
||||
|
||||
```bash
|
||||
REPO_URL=https://git.kalinamall.ru/PapaTramp/ssh-monitor.git
|
||||
REPO_URL=https://git.papatramp.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.kalinamall.ru/PapaTramp/ssh-monitor.git
|
||||
Environment=REPO_URL=https://git.papatramp.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.kalinamall.ru/PapaTramp/ssh-monitor.git ./update_ssh_monitor.sh --deploy
|
||||
sudo REPO_URL=https://git.papatramp.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.kalinamall.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
|
||||
sudo REPO_URL=https://git.papatramp.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.kalinamall.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
|
||||
0 4 * * * REPO_URL=https://git.papatramp.ru/PapaTramp/ssh-monitor.git /opt/scripts/update_ssh_monitor.sh
|
||||
```
|
||||
|
||||
### systemd timer
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Документ для эксплуатации **ssh-monitor** с `UseSAC=fallback` или `exclusive` при нагрузке на SAC (массовый update агентов, deploy backend).
|
||||
|
||||
См. также: [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).
|
||||
См. также: [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).
|
||||
|
||||
## `SAC_TIMEOUT_SEC`
|
||||
|
||||
|
||||
@@ -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.kalinamall.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.papatramp.ru/PapaTramp/security-alert-center/src/branch/main/docs/ingest-mass-update-backlog.ru.md) (отдельный ToDo).
|
||||
|
||||
---
|
||||
|
||||
|
||||
Executable → Regular
+1
-1
@@ -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.kalinamall.ru/PapaTramp/ssh-monitor/releases).
|
||||
Produces `ssh-monitor-<version>.tar.gz` (via `git archive`). Prebuilt archives are attached to [GitHub releases](https://git.papatramp.ru/PapaTramp/ssh-monitor/releases).
|
||||
|
||||
## Installing the script, config, and systemd
|
||||
|
||||
|
||||
Executable → Regular
Executable → Regular
+2
-2
@@ -77,7 +77,7 @@ MAIL_SMTP_STARTTLS="1"
|
||||
MAIL_SMTP_SSL="0"
|
||||
|
||||
# Auto-update script default (override on your server)
|
||||
# REPO_URL=https://github.com/PTah/ssh-monitor.git
|
||||
# REPO_URL=https://git.papatramp.ru/PapaTramp/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://github.com/PTah/ssh-monitor
|
||||
**Repository:** https://git.papatramp.ru/PapaTramp/ssh-monitor
|
||||
|
||||
# ssh-monitor
|
||||
|
||||
|
||||
Executable → Regular
+1
-1
@@ -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.kalinamall.ru/PapaTramp/ssh-monitor.git или Environment=REPO_URL=... в systemd unit / cron."
|
||||
local msg="ERROR: REPO_URL не задан. Задайте export REPO_URL=https://git.papatramp.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
|
||||
|
||||
Reference in New Issue
Block a user