fix28: обновлена production-документация и упаковка docs в deb
This commit is contained in:
+131
-27
@@ -1,78 +1,182 @@
|
||||
# Installation
|
||||
|
||||
Этот документ описывает production-порядок установки AWG2 Harness. Подробный runtime-план с SSH hardening и Amnezia preflight находится в корневом [`README.md`](../README.md).
|
||||
|
||||
## Deployment contract
|
||||
|
||||
- Build выполняется на отдельной Debian 13 amd64 build-machine.
|
||||
- Production-хост получает готовый Debian-пакет.
|
||||
- На production-хосте не требуются Rust/cargo/source tree.
|
||||
- Amnezia должна быть уже установлена и работать через Docker.
|
||||
- Production-конфиг создаётся вручную; [`config.example.toml`](../config.example.toml) не копируется автоматически как боевой конфиг.
|
||||
- Целевой production-хост: Debian 13 amd64.
|
||||
- Amnezia ставится до AWG2 Harness официальным self-hosted способом через приложение AmneziaVPN.
|
||||
- Проект рассчитан на AmneziaWG/AWG 2.0 и compatible legacy-сценарий AmneziaWG/AWG 1.5.
|
||||
- SSH должен быть заранее настроен. Production-пример: порт `2323`, вход по ключу, password login disabled.
|
||||
- Production-хост получает готовый Debian-пакет; Rust/cargo/source tree на нём не требуются.
|
||||
- `/etc/awg2-harness/config.toml` создаётся вручную. `config.example.toml` не копируется автоматически как боевой config.
|
||||
- Пакет не устанавливает Docker/Amnezia и не включает services автоматически.
|
||||
|
||||
## A. Build machine
|
||||
|
||||
### A1. Подготовка build environment
|
||||
### A1. Подготовить build environment
|
||||
|
||||
```bash
|
||||
cd awg2_harness
|
||||
chmod +x tools/build.sh
|
||||
./tools/build.sh --prepare-build-env --bootstrap-rust --yes
|
||||
```
|
||||
|
||||
### A2. Build и тесты
|
||||
### A2. Проверить код
|
||||
|
||||
```bash
|
||||
cargo fmt --manifest-path Cargo.toml --all --check
|
||||
cargo clippy --locked --workspace --all-targets --manifest-path Cargo.toml -- -D warnings
|
||||
cargo test --locked --workspace --release --manifest-path Cargo.toml
|
||||
```
|
||||
|
||||
То же самое выполняет build helper:
|
||||
|
||||
```bash
|
||||
./tools/build.sh --build
|
||||
```
|
||||
|
||||
### A3. Сборка пакета
|
||||
### A3. Собрать Debian-пакет
|
||||
|
||||
```bash
|
||||
./tools/build.sh --package
|
||||
./tools/build.sh --package --version 0.1.6
|
||||
sha256sum -c dist/SHA256SUMS
|
||||
dpkg-deb -I dist/awg2-harness_0.1.6_amd64.deb
|
||||
dpkg-deb -c dist/awg2-harness_0.1.6_amd64.deb | sort
|
||||
```
|
||||
|
||||
## B. Transfer artifacts
|
||||
`--version` можно опустить, если версия в `traffic_core/Cargo.toml` уже равна release version. Version override влияет только на metadata `.deb`.
|
||||
|
||||
## B. Подготовить production-хост
|
||||
|
||||
### B1. SSH
|
||||
|
||||
Production-пример:
|
||||
|
||||
```bash
|
||||
scp dist/awg2-harness_*_amd64.deb root@vpn-host:/root/
|
||||
scp config.toml root@vpn-host:/root/awg2-harness.config.toml
|
||||
install -d -m 0755 /etc/ssh/sshd_config.d
|
||||
cat >/etc/ssh/sshd_config.d/99-awg2-production.conf <<'EOF'
|
||||
Port 2323
|
||||
PermitRootLogin prohibit-password
|
||||
PasswordAuthentication no
|
||||
KbdInteractiveAuthentication no
|
||||
PubkeyAuthentication yes
|
||||
EOF
|
||||
sshd -t
|
||||
systemctl reload ssh 2>/dev/null || systemctl reload sshd
|
||||
ss -ltnp | grep ':2323'
|
||||
```
|
||||
|
||||
## C. Production host
|
||||
|
||||
### C1. Install package
|
||||
Обязательно проверьте вход с нового терминала:
|
||||
|
||||
```bash
|
||||
ssh -p 2323 root@<server-ip>
|
||||
```
|
||||
|
||||
### B2. Amnezia
|
||||
|
||||
Установите AmneziaWG/AWG через официальное приложение AmneziaVPN в режиме self-hosted server. Вводите в приложении тот SSH host/port/user/private key, который реально работает после B1.
|
||||
|
||||
Проверка после установки:
|
||||
|
||||
```bash
|
||||
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||
C="$(docker ps --format '{{.Names}}' | grep -E '^(amnezia-awg2|amnezia-awg)$' | head -n1)"
|
||||
echo "container=$C"
|
||||
docker port "$C"
|
||||
docker exec "$C" wg show
|
||||
```
|
||||
|
||||
Если контейнер называется иначе или интерфейс не `awg0`, отразите это в `/etc/awg2-harness/config.toml`.
|
||||
|
||||
## C. Transfer artifacts
|
||||
|
||||
```bash
|
||||
scp -P 2323 dist/awg2-harness_*_amd64.deb root@<server-ip>:/root/
|
||||
scp -P 2323 dist/SHA256SUMS root@<server-ip>:/root/
|
||||
scp -P 2323 config.example.toml root@<server-ip>:/root/awg2-harness.config.toml
|
||||
```
|
||||
|
||||
Перед установкой отредактируйте `/root/awg2-harness.config.toml`. Минимально проверьте:
|
||||
|
||||
- `[host_firewall].ssh_port` совпадает с реальным SSH-портом (`2323` в production-примере);
|
||||
- `[host_firewall].amnezia_port` совпадает с published UDP port Amnezia;
|
||||
- `[amnezia].peer_ipv4_cidr` совпадает с подсетью clients;
|
||||
- `[anti_torrent].peer_ipv4_cidr` обычно равен `[amnezia].peer_ipv4_cidr`;
|
||||
- `peer_limit` и `root_rate` отражают нужную traffic policy.
|
||||
|
||||
## D. Production install
|
||||
|
||||
```bash
|
||||
cd /root
|
||||
sha256sum -c SHA256SUMS
|
||||
apt install ./awg2-harness_*_amd64.deb
|
||||
```
|
||||
|
||||
### C2. Install config
|
||||
|
||||
```bash
|
||||
install -d -m 0755 /etc/awg2-harness
|
||||
install -m 0644 /root/awg2-harness.config.toml /etc/awg2-harness/config.toml
|
||||
systemctl daemon-reload
|
||||
```
|
||||
|
||||
### C3. Validate and apply
|
||||
## E. Preflight before enable
|
||||
|
||||
```bash
|
||||
awg2-harness --config /etc/awg2-harness/config.toml validate-config
|
||||
awg2-harness --config /etc/awg2-harness/config.toml validate-runtime
|
||||
awg2-harness --config /etc/awg2-harness/config.toml ensure-swap
|
||||
awg2-harness --config /etc/awg2-harness/config.toml apply-limits
|
||||
awg2-harness --config /etc/awg2-harness/config.toml apply-firewall
|
||||
awg2-harness --config /etc/awg2-harness/config.toml apply-limits
|
||||
awg2-harness --config /etc/awg2-harness/config.toml status
|
||||
```
|
||||
|
||||
When `swap.enabled=true`, AWG2 Harness will disable all other active swap entries and rewrite `/etc/fstab` swap entries to a single managed swapfile.
|
||||
Expected healthy result:
|
||||
|
||||
### C4. Enable services
|
||||
```text
|
||||
Traffic actual:
|
||||
drift: no
|
||||
Host firewall:
|
||||
drift: no
|
||||
Anti-torrent:
|
||||
drift: no
|
||||
Swap:
|
||||
drift: no
|
||||
```
|
||||
|
||||
If there are no peers yet, `apply-limits` may print `no peers found, skip tc apply`. That is healthy for an empty server.
|
||||
|
||||
When `swap.enabled=true`, AWG2 Harness intentionally makes swap exclusive: one managed swapfile, one fstab swap entry, configured swappiness.
|
||||
|
||||
## F. Enable services
|
||||
|
||||
```bash
|
||||
systemctl enable --now awg2-harness.service
|
||||
systemctl enable --now awg2-reboot-scheduler.service
|
||||
|
||||
systemctl status awg2-harness.service --no-pager -l
|
||||
systemctl status awg2-reboot-scheduler.service --no-pager -l
|
||||
journalctl -u awg2-harness.service --since '5 minutes ago' --no-pager
|
||||
journalctl -u awg2-reboot-scheduler.service --since '5 minutes ago' --no-pager
|
||||
```
|
||||
|
||||
## D. Manual source-tree install (staging/debug only)
|
||||
After 30–60 seconds:
|
||||
|
||||
Режим [`./tools/build.sh --install`](../tools/build.sh) предназначен для staging/debug с checkout-репозиторием.
|
||||
```bash
|
||||
awg2-harness --config /etc/awg2-harness/config.toml status
|
||||
```
|
||||
|
||||
Это **не** основной production deployment path.
|
||||
## G. Reboot validation
|
||||
|
||||
```bash
|
||||
reboot
|
||||
```
|
||||
|
||||
After reconnect:
|
||||
|
||||
```bash
|
||||
systemctl status docker --no-pager -l
|
||||
systemctl status awg2-harness.service --no-pager -l
|
||||
systemctl status awg2-reboot-scheduler.service --no-pager -l
|
||||
awg2-harness --config /etc/awg2-harness/config.toml status
|
||||
```
|
||||
|
||||
## H. Manual source-tree install
|
||||
|
||||
`./tools/build.sh --install` and `./tools/build.sh --enable` exist for staging/debug. They are not the recommended production path. Use `.deb` on production.
|
||||
|
||||
Reference in New Issue
Block a user