v1.8.23: upgrade ssh.py + skill for secure Claude Code integration
- Add --info (safe server details without credentials) - Add --set-note (update server notes for context) - Add --no-sudo flag documentation in skill - Fix --add leaking user@ip:port in output - Add WARNING to --list-full, forbid in skill - Add notes column to --list output - Update skill: portable path ~/.server-connections/, security rules, behavior docs - Update CLAUDE.md: security section, architecture, dev commands, doc references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
149
CLAUDE.md
149
CLAUDE.md
@@ -1,8 +1,10 @@
|
||||
# CLAUDE.md — инструкции для Claude Code
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Основная цель проекта
|
||||
|
||||
ServerManager создан чтобы **Claude Code мог управлять серверами через глобальный скилл `/ssh`**, зная только алиасы серверов. Claude **никогда не видит логины и пароли** — скрипт `ssh.py` сам читает credentials из зашифрованного `servers.json`.
|
||||
ServerManager — Desktop GUI (CustomTkinter + Paramiko) для управления удалёнными серверами. Создан чтобы **Claude Code мог управлять серверами через глобальный скилл `/ssh`**, зная только алиасы.
|
||||
|
||||
```
|
||||
Claude Code → /ssh investor "uptime" → ssh.py → servers.json (encrypted) → SSH
|
||||
@@ -10,57 +12,60 @@ Claude Code → /ssh investor "uptime" → ssh.py → servers.json (encryp
|
||||
Видит только alias + команду Пароли остаются локально Результат
|
||||
```
|
||||
|
||||
## БЕЗОПАСНОСТЬ — ГЛАВНЫЙ ПРИНЦИП
|
||||
|
||||
**Claude НИКОГДА не видит и не должен видеть:**
|
||||
- IP-адреса серверов
|
||||
- Логины (user)
|
||||
- Пароли
|
||||
- Порты
|
||||
- TOTP-секреты
|
||||
|
||||
Всё это остаётся в зашифрованном `servers.json`. Скрипт `ssh.py` сам читает credentials и подключается. Claude работает **только через алиасы**.
|
||||
|
||||
**ЗАПРЕЩЕНО:**
|
||||
- Читать файлы в `~/.server-connections/` напрямую
|
||||
- Использовать `ssh.py --list-full` (выводит IP/логины)
|
||||
- Добавлять IP/логины/пароли в memory bank, контекст, логи
|
||||
|
||||
## Команды разработки
|
||||
|
||||
```bash
|
||||
# Запуск приложения
|
||||
python main.py
|
||||
|
||||
# Сборка exe (автоматически бампит patch-версию)
|
||||
python build.py
|
||||
|
||||
# Сборка без бампа версии
|
||||
python build.py --no-bump
|
||||
|
||||
# Очистка артефактов + сборка
|
||||
python build.py --clean
|
||||
|
||||
# Установка зависимостей
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Как пользоваться /ssh
|
||||
|
||||
```bash
|
||||
# Выполнить команду на сервере
|
||||
/ssh investor "uptime"
|
||||
/ssh main-ovh "systemctl status nginx"
|
||||
|
||||
# Список серверов (без паролей)
|
||||
/ssh --list
|
||||
|
||||
# Статус всех серверов
|
||||
/ssh --status
|
||||
|
||||
# Загрузить файл
|
||||
/ssh investor --upload /local/file /remote/path
|
||||
|
||||
# Скачать файл
|
||||
/ssh investor --download /remote/file /local/path
|
||||
|
||||
# Проверить доступность
|
||||
/ssh investor --ping
|
||||
/ssh investor "uptime" # Выполнить команду
|
||||
/ssh main-ovh "systemctl status nginx" # Команда на другом сервере
|
||||
/ssh --list # Список серверов (без паролей)
|
||||
/ssh --status # Статус всех серверов
|
||||
/ssh investor --upload /local/file /remote/ # Загрузить файл
|
||||
/ssh investor --download /remote/file /local/ # Скачать файл
|
||||
/ssh investor --ping # Проверить доступность
|
||||
```
|
||||
|
||||
## Как настроить на новой машине
|
||||
|
||||
1. Клонировать: `git clone https://git.sensey24.ru/aibot777/server-manager.git`
|
||||
2. `pip install -r requirements.txt`
|
||||
3. `python main.py` → вкладка Setup → "Install Everything"
|
||||
4. Добавить серверы через GUI → Claude Code сразу видит их через `/ssh --list`
|
||||
|
||||
Setup устанавливает:
|
||||
- `ssh.py` → `~/.server-connections/`
|
||||
- `encryption.py` → `~/.server-connections/`
|
||||
- `/ssh` skill → `~/.claude/commands/ssh.md`
|
||||
- SSH-ключ (ed25519)
|
||||
|
||||
## Версионирование
|
||||
|
||||
**Автоматическое.** `build.py` сам инкрементирует patch-версию при каждой сборке.
|
||||
**Автоматическое.** `build.py` инкрементирует patch в `version.py` → `__version__` при каждой сборке.
|
||||
|
||||
```bash
|
||||
python build.py # автобамп 1.8.9 → 1.8.10, сборка
|
||||
python build.py --no-bump # сборка без изменения версии
|
||||
python build.py --clean # очистка артефактов + сборка
|
||||
```
|
||||
Semver: **MAJOR** (ломающие) | **MINOR** (новая фича) | **PATCH** (автобамп при сборке)
|
||||
|
||||
Файл версии: `version.py` → `__version__`
|
||||
|
||||
Semver: **MAJOR** (ломающие) | **MINOR** (новая фича) | **PATCH** (багфикс — автобамп)
|
||||
|
||||
Для minor/major бампа — вручную изменить version.py перед сборкой.
|
||||
Для minor/major бампа — вручную изменить `version.py` перед `python build.py --no-bump`.
|
||||
|
||||
## Git — коммит и пуш
|
||||
|
||||
@@ -78,23 +83,23 @@ git push sensey master
|
||||
|
||||
```
|
||||
ServerManager/
|
||||
├── main.py # Entry point
|
||||
├── version.py # Version (auto-bumped by build.py)
|
||||
├── main.py # Entry point → gui/app.py
|
||||
├── version.py # __version__ (auto-bumped by build.py)
|
||||
├── build.py # PyInstaller + auto version bump
|
||||
├── core/ # Business logic
|
||||
│ ├── server_store.py # CRUD + encrypted JSON + backups
|
||||
│ ├── encryption.py # Fernet encryption
|
||||
│ ├── ssh_client.py # Paramiko SSH/SFTP/ShellSession
|
||||
│ ├── server_store.py # CRUD + encrypted JSON + observer pattern + backups
|
||||
│ ├── encryption.py # Fernet symmetric encryption
|
||||
│ ├── ssh_client.py # Paramiko: ShellSession + SFTPSession
|
||||
│ ├── session_pool.py # LRU session pool (max 5 concurrent)
|
||||
│ ├── claude_setup.py # Claude Code integration installer
|
||||
│ ├── status_checker.py # Background monitoring
|
||||
│ ├── status_checker.py # Background monitoring (every 60s)
|
||||
│ ├── totp.py # TOTP/2FA (pyotp)
|
||||
│ ├── i18n.py # EN/RU/ZH translations
|
||||
│ ├── i18n.py # EN/RU/ZH translations, t(key) API
|
||||
│ └── logger.py # Rotating file logger
|
||||
├── gui/ # CustomTkinter UI
|
||||
│ ├── app.py # Main window
|
||||
│ ├── sidebar.py # Server list + session indicators
|
||||
│ ├── tabs/ # Terminal, Files, Info, Keys, 2FA, Setup
|
||||
│ ├── app.py # Main window: sidebar + tabview
|
||||
│ ├── sidebar.py # Server list + session indicators + search
|
||||
│ ├── tabs/ # Terminal, Files, Info, Keys, TOTP, Setup
|
||||
│ └── widgets/ # TerminalWidget (pyte), FileList, StatusBadge
|
||||
├── tools/ # CLI tools (installed to ~/.server-connections/)
|
||||
│ ├── ssh.py # SSH utility for Claude Code
|
||||
@@ -102,11 +107,35 @@ ServerManager/
|
||||
└── releases/ # Built executables
|
||||
```
|
||||
|
||||
## Ключевые особенности терминала
|
||||
|
||||
- **pyte** эмулятор + tkinter Text виджет
|
||||
**Ключевые паттерны:**
|
||||
- Терминал использует **pyte** для эмуляции VT-терминала поверх tkinter Text виджета
|
||||
- **Session pool** — сессии живут при переключении серверов, буфер сохраняется через pickle
|
||||
- **Auto-sudo** — детекция `[sudo] password for` в выводе, автоматическая отправка пароля
|
||||
- **Ctrl+C** — double-press (1.5s) для SIGINT, single = copy (если есть выделение)
|
||||
- **Auto-sudo** — детекция `[sudo] password for` в выводе, автоматическая отправка пароля через stdin
|
||||
- **Keyboard layout independent** — Ctrl+C/V/D/L/Z работают через keycode, не зависят от раскладки
|
||||
- **Copy/Paste** — Ctrl+C/Ctrl+Shift+C/правый клик для копирования, Ctrl+V для вставки (с bracketed paste)
|
||||
- GUI общается с `ServerStore` через observer pattern — изменения в хранилище автоматически обновляют UI
|
||||
|
||||
## Настройка на новой машине
|
||||
|
||||
1. `git clone https://git.sensey24.ru/aibot777/server-manager.git`
|
||||
2. `pip install -r requirements.txt`
|
||||
3. `python main.py` → вкладка Setup → "Install Everything"
|
||||
4. Добавить серверы через GUI → Claude Code видит их через `/ssh --list`
|
||||
|
||||
Setup устанавливает: `ssh.py` + `encryption.py` → `~/.server-connections/`, скилл `/ssh` → `~/.claude/commands/ssh.md`, SSH-ключ ed25519.
|
||||
|
||||
## Конфигурация
|
||||
|
||||
- Серверы: `~/.server-connections/servers.json` (Fernet-encrypted)
|
||||
- Настройки: `~/.server-connections/settings.json`
|
||||
- Бэкапы: `~/.server-connections/backups/`
|
||||
- Путь конфига можно сменить через GUI: Setup → Configuration → "Change Path"
|
||||
|
||||
## Дополнительная документация
|
||||
|
||||
Читай эти файлы **по необходимости**, а не заранее:
|
||||
|
||||
- `README.md` — полное описание фич, установка, использование (EN/RU/ZH)
|
||||
- `CHANGELOG.md` — история изменений по версиям
|
||||
- `TERMINAL_AUDIT.md` — аудит терминала: что сделано/не сделано для TUI-совместимости (pyte, 256-color, alternate screen и т.д.)
|
||||
- `plans/` — планы реализации конкретных фич (шифрование, TOTP, undo и др.)
|
||||
- `tools/skill-ssh.md` — шаблон скилла `/ssh` (устанавливается в `~/.claude/commands/`)
|
||||
|
||||
Reference in New Issue
Block a user