remote-admin-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- remote_admin_mcp-0.1.0/.env.example +21 -0
- remote_admin_mcp-0.1.0/.github/workflows/publish.yml +27 -0
- remote_admin_mcp-0.1.0/.gitignore +12 -0
- remote_admin_mcp-0.1.0/LICENSE +21 -0
- remote_admin_mcp-0.1.0/PKG-INFO +268 -0
- remote_admin_mcp-0.1.0/README.md +243 -0
- remote_admin_mcp-0.1.0/docs/architecture.md +330 -0
- remote_admin_mcp-0.1.0/docs/prompt-large-file-handling.md +138 -0
- remote_admin_mcp-0.1.0/pyproject.toml +56 -0
- remote_admin_mcp-0.1.0/run.sh +24 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/__init__.py +3 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/audit.py +12 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/config.py +35 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/models.py +18 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/server.py +393 -0
- remote_admin_mcp-0.1.0/src/ssh_mcp/ssh_client.py +226 -0
- remote_admin_mcp-0.1.0/tests/test_models.py +25 -0
- remote_admin_mcp-0.1.0/uv.lock +1069 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# SSH Server Configuration Examples
|
|
2
|
+
|
|
3
|
+
# Server 1
|
|
4
|
+
SSH_SERVER_1_NAME=production
|
|
5
|
+
SSH_SERVER_1_HOST=prod.example.com
|
|
6
|
+
SSH_SERVER_1_PORT=22
|
|
7
|
+
SSH_SERVER_1_USER=admin
|
|
8
|
+
SSH_SERVER_1_PASSWORD=your-password-here
|
|
9
|
+
|
|
10
|
+
# Server 2
|
|
11
|
+
SSH_SERVER_2_NAME=staging
|
|
12
|
+
SSH_SERVER_2_HOST=staging.example.com
|
|
13
|
+
SSH_SERVER_2_PORT=22
|
|
14
|
+
SSH_SERVER_2_USER=deploy
|
|
15
|
+
SSH_SERVER_2_PASSWORD=your-password-here
|
|
16
|
+
|
|
17
|
+
# Add more servers by incrementing the number
|
|
18
|
+
# SSH_SERVER_3_NAME=...
|
|
19
|
+
|
|
20
|
+
# Audit Log (optional, default: ~/.ssh-mcp-audit.log)
|
|
21
|
+
# SSH_MCP_AUDIT_LOG=/var/log/ssh-mcp-audit.log
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.10"
|
|
20
|
+
|
|
21
|
+
- name: Build
|
|
22
|
+
run: |
|
|
23
|
+
pip install build
|
|
24
|
+
python -m build
|
|
25
|
+
|
|
26
|
+
- name: Publish to PyPI
|
|
27
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Frank Schaellert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: remote-admin-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP Server for remote server administration via SSH — execute commands, manage files, edit configs, transfer files, control services. No agents needed on target servers.
|
|
5
|
+
Project-URL: Homepage, https://github.com/intershopper/remote-admin-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/intershopper/remote-admin-mcp
|
|
7
|
+
Author-email: Frank Schaellert <intershopper@gmx.de>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: mcp>=1.26.0
|
|
15
|
+
Requires-Dist: paramiko>=3.4.0
|
|
16
|
+
Requires-Dist: pyjwt[crypto]>=2.12.0
|
|
17
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
18
|
+
Requires-Dist: starlette>=0.38.0
|
|
19
|
+
Requires-Dist: uvicorn>=0.30.0
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.3.0; extra == 'dev'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# SSH MCP Server
|
|
27
|
+
|
|
28
|
+
MCP Server für SSH-basierte Server-Administration. Ermöglicht KI-Assistenten die Verwaltung von Remote-Servern via SSH.
|
|
29
|
+
|
|
30
|
+
## Supported MCP Clients
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
graph LR
|
|
34
|
+
subgraph Getestet
|
|
35
|
+
K[Kiro CLI]
|
|
36
|
+
C[Claude Desktop]
|
|
37
|
+
end
|
|
38
|
+
subgraph Kompatibel
|
|
39
|
+
A[Alle MCP-fähigen Clients<br/>stdio + StreamableHTTP]
|
|
40
|
+
end
|
|
41
|
+
K --> MCP[SSH MCP Server]
|
|
42
|
+
C --> MCP
|
|
43
|
+
A --> MCP
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Client | Transport | Status |
|
|
47
|
+
|--------|-----------|--------|
|
|
48
|
+
| [Kiro CLI](https://github.com/aws/kiro) | stdio | ✅ getestet |
|
|
49
|
+
| [Claude Desktop](https://claude.ai/download) | stdio | ✅ getestet |
|
|
50
|
+
| Jeder MCP-Client | stdio / StreamableHTTP | ✅ kompatibel |
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
Verwalte Linux-Server per SSH — direkt aus dem KI-Assistenten heraus. Keine Agents, Daemons oder Tools auf den Zielservern nötig. Nur ein SSH-Zugang reicht.
|
|
55
|
+
|
|
56
|
+
```mermaid
|
|
57
|
+
graph LR
|
|
58
|
+
AI[KI-Assistent] -->|MCP| S[SSH MCP Server]
|
|
59
|
+
S -->|SSH/SFTP| R1[Server 1]
|
|
60
|
+
S -->|SSH/SFTP| R2[Server 2]
|
|
61
|
+
S -->|SSH/SFTP| RN[Server N]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- **Agentless**: Kein Setup auf den Zielservern — funktioniert mit jedem SSH-Zugang
|
|
65
|
+
- **Remote Command Execution**: Einzelbefehle oder mehrzeilige Scripts ausführen
|
|
66
|
+
- **Sudo Support**: Befehle mit `sudo` ausführen, ohne interaktives Passwort
|
|
67
|
+
- **File Operations**: Dateien lesen (teilweise/komplett), schreiben, suchen, chirurgisch editieren
|
|
68
|
+
- **File Transfer**: Upload/Download via SFTP
|
|
69
|
+
- **Service Management**: Systemd Services starten, stoppen, restarten, Status prüfen
|
|
70
|
+
- **Code Navigation**: Funktions-/Klassen-Übersicht aus Quelldateien extrahieren (grep-basiert, kein Language Server nötig)
|
|
71
|
+
- **Multi-Server**: Beliebig viele Server parallel verwalten
|
|
72
|
+
- **Connection Pooling**: SSH-Verbindungen werden 5 Minuten wiederverwendet
|
|
73
|
+
- **User Approval**: Schreibende Operationen erfordern Bestätigung durch den Operator
|
|
74
|
+
- **Audit Log**: Alle Aktionen werden protokolliert (Pfad konfigurierbar)
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
### Von PyPI
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install remote-admin-mcp
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Mit uv (empfohlen für Entwicklung)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Virtuelle Umgebung erstellen und Abhängigkeiten installieren
|
|
88
|
+
uv venv
|
|
89
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
90
|
+
uv pip install -e ".[dev]"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Mit pip
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Virtuelle Umgebung erstellen
|
|
97
|
+
python -m venv .venv
|
|
98
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
99
|
+
|
|
100
|
+
# Abhängigkeiten installieren
|
|
101
|
+
pip install -e ".[dev]"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Konfiguration
|
|
105
|
+
|
|
106
|
+
1. Kopiere `.env.example` zu `.env`:
|
|
107
|
+
```bash
|
|
108
|
+
cp .env.example .env
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. Bearbeite `.env` mit deinen Server-Zugangsdaten:
|
|
112
|
+
```bash
|
|
113
|
+
SSH_SERVER_1_NAME=production
|
|
114
|
+
SSH_SERVER_1_HOST=prod.example.com
|
|
115
|
+
SSH_SERVER_1_PORT=22
|
|
116
|
+
SSH_SERVER_1_USER=admin
|
|
117
|
+
SSH_SERVER_1_PASSWORD=your-password
|
|
118
|
+
|
|
119
|
+
SSH_SERVER_2_NAME=staging
|
|
120
|
+
SSH_SERVER_2_HOST=staging.example.com
|
|
121
|
+
SSH_SERVER_2_PORT=22
|
|
122
|
+
SSH_SERVER_2_USER=deploy
|
|
123
|
+
SSH_SERVER_2_PASSWORD=your-password
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## MCP Tools
|
|
127
|
+
|
|
128
|
+
### list_servers
|
|
129
|
+
Liste alle konfigurierten Server auf.
|
|
130
|
+
|
|
131
|
+
### execute_command
|
|
132
|
+
Führe einen Befehl auf einem Remote-Server aus.
|
|
133
|
+
|
|
134
|
+
**Parameter:**
|
|
135
|
+
- `server` (string): Server-Name
|
|
136
|
+
- `command` (string): Auszuführender Befehl
|
|
137
|
+
- `use_sudo` (boolean): Mit sudo ausführen
|
|
138
|
+
|
|
139
|
+
### read_file
|
|
140
|
+
Lese eine Datei vom Remote-Server.
|
|
141
|
+
|
|
142
|
+
**Parameter:**
|
|
143
|
+
- `server` (string): Server-Name
|
|
144
|
+
- `path` (string): Dateipfad
|
|
145
|
+
|
|
146
|
+
### write_file
|
|
147
|
+
Schreibe eine Datei auf den Remote-Server.
|
|
148
|
+
|
|
149
|
+
**Parameter:**
|
|
150
|
+
- `server` (string): Server-Name
|
|
151
|
+
- `path` (string): Dateipfad
|
|
152
|
+
- `content` (string): Dateiinhalt
|
|
153
|
+
|
|
154
|
+
### get_service_status
|
|
155
|
+
Prüfe den Status eines systemd Services.
|
|
156
|
+
|
|
157
|
+
**Parameter:**
|
|
158
|
+
- `server` (string): Server-Name
|
|
159
|
+
- `service` (string): Service-Name
|
|
160
|
+
|
|
161
|
+
### manage_service
|
|
162
|
+
Verwalte einen systemd Service (start/stop/restart/reload).
|
|
163
|
+
|
|
164
|
+
**Parameter:**
|
|
165
|
+
- `server` (string): Server-Name
|
|
166
|
+
- `service` (string): Service-Name
|
|
167
|
+
- `action` (string): Aktion (start/stop/restart/reload)
|
|
168
|
+
|
|
169
|
+
## Verwendung mit KI-Assistenten
|
|
170
|
+
|
|
171
|
+
### Kiro CLI / Claude Desktop (uvx — empfohlen)
|
|
172
|
+
|
|
173
|
+
Kein manuelles Installieren nötig — `uvx` lädt und cached das Paket automatisch:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"ssh": {
|
|
179
|
+
"command": "uvx",
|
|
180
|
+
"args": ["remote-admin-mcp"],
|
|
181
|
+
"env": {
|
|
182
|
+
"SSH_SERVER_1_NAME": "production",
|
|
183
|
+
"SSH_SERVER_1_HOST": "prod.example.com",
|
|
184
|
+
"SSH_SERVER_1_USER": "admin",
|
|
185
|
+
"SSH_SERVER_1_KEY_FILE": "~/.ssh/id_ed25519"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Alternative: Mit .env-Datei
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"mcpServers": {
|
|
197
|
+
"ssh": {
|
|
198
|
+
"command": "uvx",
|
|
199
|
+
"args": ["--env-file", "/path/to/.env", "remote-admin-mcp"]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Alternative: Lokale Installation
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"mcpServers": {
|
|
210
|
+
"ssh": {
|
|
211
|
+
"command": "/path/to/.venv/bin/ssh_mcp_server"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Beispiele
|
|
218
|
+
|
|
219
|
+
**Log-Analyse:**
|
|
220
|
+
```
|
|
221
|
+
"Zeige mir die letzten 100 Zeilen vom nginx error log auf production"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Service Restart:**
|
|
225
|
+
```
|
|
226
|
+
"Starte den nginx Service auf staging neu"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Config ändern:**
|
|
230
|
+
```
|
|
231
|
+
"Lies die nginx.conf auf production und erhöhe worker_processes auf 4"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Sicherheit
|
|
235
|
+
|
|
236
|
+
- Schreibende Tools erfordern **User-Approval** durch den MCP Client
|
|
237
|
+
- Lese-Tools (`list_servers`, `read_file`, `search_in_file`, `get_file_structure`) sind auto-approved
|
|
238
|
+
- SSH-Key-Authentifizierung empfohlen (Passwort-Auth möglich)
|
|
239
|
+
- `.env` sollte NICHT ins Git committed werden
|
|
240
|
+
|
|
241
|
+
### Audit Log
|
|
242
|
+
|
|
243
|
+
Alle Aktionen werden in ein Logfile geschrieben:
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
[2026-04-12 13:14:00] [production] execute: tail -100 /var/log/syslog
|
|
247
|
+
[2026-04-12 13:14:05] [production] write_file: /etc/nginx/nginx.conf — Config update
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Default: `~/.ssh-mcp-audit.log`. Konfigurierbar per Environment-Variable:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
SSH_MCP_AUDIT_LOG=/var/log/ssh-mcp-audit.log
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Entwicklung
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Tests ausführen
|
|
260
|
+
pytest -v
|
|
261
|
+
|
|
262
|
+
# Linting
|
|
263
|
+
ruff check src/
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Lizenz
|
|
267
|
+
|
|
268
|
+
MIT — siehe [LICENSE](LICENSE)
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# SSH MCP Server
|
|
2
|
+
|
|
3
|
+
MCP Server für SSH-basierte Server-Administration. Ermöglicht KI-Assistenten die Verwaltung von Remote-Servern via SSH.
|
|
4
|
+
|
|
5
|
+
## Supported MCP Clients
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph LR
|
|
9
|
+
subgraph Getestet
|
|
10
|
+
K[Kiro CLI]
|
|
11
|
+
C[Claude Desktop]
|
|
12
|
+
end
|
|
13
|
+
subgraph Kompatibel
|
|
14
|
+
A[Alle MCP-fähigen Clients<br/>stdio + StreamableHTTP]
|
|
15
|
+
end
|
|
16
|
+
K --> MCP[SSH MCP Server]
|
|
17
|
+
C --> MCP
|
|
18
|
+
A --> MCP
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Client | Transport | Status |
|
|
22
|
+
|--------|-----------|--------|
|
|
23
|
+
| [Kiro CLI](https://github.com/aws/kiro) | stdio | ✅ getestet |
|
|
24
|
+
| [Claude Desktop](https://claude.ai/download) | stdio | ✅ getestet |
|
|
25
|
+
| Jeder MCP-Client | stdio / StreamableHTTP | ✅ kompatibel |
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
Verwalte Linux-Server per SSH — direkt aus dem KI-Assistenten heraus. Keine Agents, Daemons oder Tools auf den Zielservern nötig. Nur ein SSH-Zugang reicht.
|
|
30
|
+
|
|
31
|
+
```mermaid
|
|
32
|
+
graph LR
|
|
33
|
+
AI[KI-Assistent] -->|MCP| S[SSH MCP Server]
|
|
34
|
+
S -->|SSH/SFTP| R1[Server 1]
|
|
35
|
+
S -->|SSH/SFTP| R2[Server 2]
|
|
36
|
+
S -->|SSH/SFTP| RN[Server N]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- **Agentless**: Kein Setup auf den Zielservern — funktioniert mit jedem SSH-Zugang
|
|
40
|
+
- **Remote Command Execution**: Einzelbefehle oder mehrzeilige Scripts ausführen
|
|
41
|
+
- **Sudo Support**: Befehle mit `sudo` ausführen, ohne interaktives Passwort
|
|
42
|
+
- **File Operations**: Dateien lesen (teilweise/komplett), schreiben, suchen, chirurgisch editieren
|
|
43
|
+
- **File Transfer**: Upload/Download via SFTP
|
|
44
|
+
- **Service Management**: Systemd Services starten, stoppen, restarten, Status prüfen
|
|
45
|
+
- **Code Navigation**: Funktions-/Klassen-Übersicht aus Quelldateien extrahieren (grep-basiert, kein Language Server nötig)
|
|
46
|
+
- **Multi-Server**: Beliebig viele Server parallel verwalten
|
|
47
|
+
- **Connection Pooling**: SSH-Verbindungen werden 5 Minuten wiederverwendet
|
|
48
|
+
- **User Approval**: Schreibende Operationen erfordern Bestätigung durch den Operator
|
|
49
|
+
- **Audit Log**: Alle Aktionen werden protokolliert (Pfad konfigurierbar)
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
### Von PyPI
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install remote-admin-mcp
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Mit uv (empfohlen für Entwicklung)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Virtuelle Umgebung erstellen und Abhängigkeiten installieren
|
|
63
|
+
uv venv
|
|
64
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
65
|
+
uv pip install -e ".[dev]"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Mit pip
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Virtuelle Umgebung erstellen
|
|
72
|
+
python -m venv .venv
|
|
73
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
74
|
+
|
|
75
|
+
# Abhängigkeiten installieren
|
|
76
|
+
pip install -e ".[dev]"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Konfiguration
|
|
80
|
+
|
|
81
|
+
1. Kopiere `.env.example` zu `.env`:
|
|
82
|
+
```bash
|
|
83
|
+
cp .env.example .env
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
2. Bearbeite `.env` mit deinen Server-Zugangsdaten:
|
|
87
|
+
```bash
|
|
88
|
+
SSH_SERVER_1_NAME=production
|
|
89
|
+
SSH_SERVER_1_HOST=prod.example.com
|
|
90
|
+
SSH_SERVER_1_PORT=22
|
|
91
|
+
SSH_SERVER_1_USER=admin
|
|
92
|
+
SSH_SERVER_1_PASSWORD=your-password
|
|
93
|
+
|
|
94
|
+
SSH_SERVER_2_NAME=staging
|
|
95
|
+
SSH_SERVER_2_HOST=staging.example.com
|
|
96
|
+
SSH_SERVER_2_PORT=22
|
|
97
|
+
SSH_SERVER_2_USER=deploy
|
|
98
|
+
SSH_SERVER_2_PASSWORD=your-password
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## MCP Tools
|
|
102
|
+
|
|
103
|
+
### list_servers
|
|
104
|
+
Liste alle konfigurierten Server auf.
|
|
105
|
+
|
|
106
|
+
### execute_command
|
|
107
|
+
Führe einen Befehl auf einem Remote-Server aus.
|
|
108
|
+
|
|
109
|
+
**Parameter:**
|
|
110
|
+
- `server` (string): Server-Name
|
|
111
|
+
- `command` (string): Auszuführender Befehl
|
|
112
|
+
- `use_sudo` (boolean): Mit sudo ausführen
|
|
113
|
+
|
|
114
|
+
### read_file
|
|
115
|
+
Lese eine Datei vom Remote-Server.
|
|
116
|
+
|
|
117
|
+
**Parameter:**
|
|
118
|
+
- `server` (string): Server-Name
|
|
119
|
+
- `path` (string): Dateipfad
|
|
120
|
+
|
|
121
|
+
### write_file
|
|
122
|
+
Schreibe eine Datei auf den Remote-Server.
|
|
123
|
+
|
|
124
|
+
**Parameter:**
|
|
125
|
+
- `server` (string): Server-Name
|
|
126
|
+
- `path` (string): Dateipfad
|
|
127
|
+
- `content` (string): Dateiinhalt
|
|
128
|
+
|
|
129
|
+
### get_service_status
|
|
130
|
+
Prüfe den Status eines systemd Services.
|
|
131
|
+
|
|
132
|
+
**Parameter:**
|
|
133
|
+
- `server` (string): Server-Name
|
|
134
|
+
- `service` (string): Service-Name
|
|
135
|
+
|
|
136
|
+
### manage_service
|
|
137
|
+
Verwalte einen systemd Service (start/stop/restart/reload).
|
|
138
|
+
|
|
139
|
+
**Parameter:**
|
|
140
|
+
- `server` (string): Server-Name
|
|
141
|
+
- `service` (string): Service-Name
|
|
142
|
+
- `action` (string): Aktion (start/stop/restart/reload)
|
|
143
|
+
|
|
144
|
+
## Verwendung mit KI-Assistenten
|
|
145
|
+
|
|
146
|
+
### Kiro CLI / Claude Desktop (uvx — empfohlen)
|
|
147
|
+
|
|
148
|
+
Kein manuelles Installieren nötig — `uvx` lädt und cached das Paket automatisch:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"ssh": {
|
|
154
|
+
"command": "uvx",
|
|
155
|
+
"args": ["remote-admin-mcp"],
|
|
156
|
+
"env": {
|
|
157
|
+
"SSH_SERVER_1_NAME": "production",
|
|
158
|
+
"SSH_SERVER_1_HOST": "prod.example.com",
|
|
159
|
+
"SSH_SERVER_1_USER": "admin",
|
|
160
|
+
"SSH_SERVER_1_KEY_FILE": "~/.ssh/id_ed25519"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Alternative: Mit .env-Datei
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"ssh": {
|
|
173
|
+
"command": "uvx",
|
|
174
|
+
"args": ["--env-file", "/path/to/.env", "remote-admin-mcp"]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Alternative: Lokale Installation
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"mcpServers": {
|
|
185
|
+
"ssh": {
|
|
186
|
+
"command": "/path/to/.venv/bin/ssh_mcp_server"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Beispiele
|
|
193
|
+
|
|
194
|
+
**Log-Analyse:**
|
|
195
|
+
```
|
|
196
|
+
"Zeige mir die letzten 100 Zeilen vom nginx error log auf production"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Service Restart:**
|
|
200
|
+
```
|
|
201
|
+
"Starte den nginx Service auf staging neu"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Config ändern:**
|
|
205
|
+
```
|
|
206
|
+
"Lies die nginx.conf auf production und erhöhe worker_processes auf 4"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Sicherheit
|
|
210
|
+
|
|
211
|
+
- Schreibende Tools erfordern **User-Approval** durch den MCP Client
|
|
212
|
+
- Lese-Tools (`list_servers`, `read_file`, `search_in_file`, `get_file_structure`) sind auto-approved
|
|
213
|
+
- SSH-Key-Authentifizierung empfohlen (Passwort-Auth möglich)
|
|
214
|
+
- `.env` sollte NICHT ins Git committed werden
|
|
215
|
+
|
|
216
|
+
### Audit Log
|
|
217
|
+
|
|
218
|
+
Alle Aktionen werden in ein Logfile geschrieben:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
[2026-04-12 13:14:00] [production] execute: tail -100 /var/log/syslog
|
|
222
|
+
[2026-04-12 13:14:05] [production] write_file: /etc/nginx/nginx.conf — Config update
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Default: `~/.ssh-mcp-audit.log`. Konfigurierbar per Environment-Variable:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
SSH_MCP_AUDIT_LOG=/var/log/ssh-mcp-audit.log
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Entwicklung
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Tests ausführen
|
|
235
|
+
pytest -v
|
|
236
|
+
|
|
237
|
+
# Linting
|
|
238
|
+
ruff check src/
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Lizenz
|
|
242
|
+
|
|
243
|
+
MIT — siehe [LICENSE](LICENSE)
|