mcp-ssh-manager 3.0.0

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.
Files changed (56) hide show
  1. package/.claude/settings.local.json +87 -0
  2. package/.flake8 +15 -0
  3. package/.hooks-config.json +131 -0
  4. package/.pre-commit-config.yaml +105 -0
  5. package/CHANGELOG.md +137 -0
  6. package/CLAUDE.md +190 -0
  7. package/CONTRIBUTING.md +114 -0
  8. package/DESCRIPTION +1 -0
  9. package/INSTALLATION.md +180 -0
  10. package/LICENSE +21 -0
  11. package/QUICKSTART.md +77 -0
  12. package/README.md +718 -0
  13. package/cli/README.md +286 -0
  14. package/cli/build.sh +199 -0
  15. package/cli/commands/server.sh +284 -0
  16. package/cli/demo.sh +107 -0
  17. package/cli/install.sh +164 -0
  18. package/cli/lib/colors.sh +174 -0
  19. package/cli/lib/config.sh +284 -0
  20. package/cli/lib/menu.sh +430 -0
  21. package/cli/migrate.sh +168 -0
  22. package/cli/ssh-manager +525 -0
  23. package/docs/ALIASES_AND_HOOKS.md +285 -0
  24. package/docs/BACKUP_GUIDE.md +500 -0
  25. package/docs/DEPLOYMENT_GUIDE.md +241 -0
  26. package/docs/SEO.md +257 -0
  27. package/examples/backup-workflow.js +481 -0
  28. package/examples/claude-code-config.example.json +40 -0
  29. package/examples/codex-ssh-config.example.toml +71 -0
  30. package/examples/deploy-workflow.py +183 -0
  31. package/glama.json +6 -0
  32. package/package.json +85 -0
  33. package/profiles/README.md +40 -0
  34. package/profiles/default.json +52 -0
  35. package/profiles/docker.json +62 -0
  36. package/profiles/frappe.json +107 -0
  37. package/profiles/nodejs.json +63 -0
  38. package/pyproject.toml +17 -0
  39. package/scripts/setup-hooks.sh +60 -0
  40. package/scripts/validate.sh +76 -0
  41. package/src/backup-manager.js +469 -0
  42. package/src/command-aliases.js +151 -0
  43. package/src/config-loader.js +281 -0
  44. package/src/database-manager.js +555 -0
  45. package/src/deploy-helper.js +176 -0
  46. package/src/health-monitor.js +428 -0
  47. package/src/hooks-system.js +327 -0
  48. package/src/index.js +4499 -0
  49. package/src/logger.js +276 -0
  50. package/src/profile-loader.js +187 -0
  51. package/src/server-aliases.js +150 -0
  52. package/src/server-groups.js +409 -0
  53. package/src/session-manager.js +410 -0
  54. package/src/ssh-key-manager.js +378 -0
  55. package/src/ssh-manager.js +435 -0
  56. package/src/tunnel-manager.js +576 -0
@@ -0,0 +1,241 @@
1
+ # SSH Manager Deployment Guide 🚀
2
+
3
+ ## Overview
4
+
5
+ The MCP SSH Manager now includes advanced deployment features that solve common deployment challenges:
6
+
7
+ - ✅ Automatic permission handling
8
+ - ✅ Secure sudo execution
9
+ - ✅ Server aliases for easier access
10
+ - ✅ Batch file deployments
11
+ - ✅ Automatic backups before deployment
12
+
13
+ ## New Tools
14
+
15
+ ### 1. `ssh_deploy` - Automated File Deployment
16
+
17
+ Deploy files with automatic permission handling and backup.
18
+
19
+ #### Basic Usage
20
+
21
+ ```
22
+ "Deploy my config file to production server"
23
+ "Upload all JavaScript files to staging"
24
+ ```
25
+
26
+ #### Advanced Usage with Options
27
+
28
+ ```json
29
+ {
30
+ "server": "production",
31
+ "files": [
32
+ {
33
+ "local": "/local/path/file.js",
34
+ "remote": "/var/www/app/file.js"
35
+ }
36
+ ],
37
+ "options": {
38
+ "owner": "www-data:www-data",
39
+ "permissions": "644",
40
+ "backup": true,
41
+ "restart": "systemctl restart nginx"
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### 2. `ssh_execute_sudo` - Execute with Sudo
47
+
48
+ Run commands with sudo privileges securely.
49
+
50
+ ```
51
+ "Run 'apt update' on production with sudo"
52
+ "Execute 'systemctl restart nginx' as root on staging"
53
+ ```
54
+
55
+ ### 3. `ssh_alias` - Manage Server Aliases
56
+
57
+ Create shortcuts for your servers.
58
+
59
+ ```
60
+ "Create alias 'prod' for production server"
61
+ "List all server aliases"
62
+ "Remove alias 'old-server'"
63
+ ```
64
+
65
+ ## Common Deployment Workflows
66
+
67
+ ### ERPNext/Frappe Deployment
68
+
69
+ For the scenario from your conversation, here's the optimized workflow:
70
+
71
+ ```
72
+ # Step 1: Create aliases for easier access
73
+ "Create alias 'dmis' for dmis server"
74
+
75
+ # Step 2: Deploy files using the new tool
76
+ "Deploy payment_proposal.py and payment_proposal.js to dmis:/home/neoffice/frappe-bench/apps/erpnextswiss/"
77
+
78
+ # Step 3: Restart the service
79
+ "Run 'bench restart' on dmis"
80
+ ```
81
+
82
+ The deployment tool automatically:
83
+ - Uploads to a temp location first
84
+ - Moves files to the correct location
85
+ - Handles permissions if needed
86
+ - Creates backups of existing files
87
+
88
+ ### Web Application Deployment
89
+
90
+ ```
91
+ # Deploy with automatic nginx restart
92
+ "Deploy index.html to production:/var/www/html with nginx restart"
93
+
94
+ # This single command:
95
+ # 1. Backs up existing index.html
96
+ # 2. Uploads new file to temp
97
+ # 3. Moves to final location with correct permissions
98
+ # 4. Restarts nginx
99
+ ```
100
+
101
+ ### Configuration File Updates
102
+
103
+ ```
104
+ # Deploy sensitive config with proper permissions
105
+ "Deploy nginx.conf to prod:/etc/nginx/ with owner root:root and permissions 644"
106
+ ```
107
+
108
+ ## Security Best Practices
109
+
110
+ ### 1. Sudo Password Handling
111
+
112
+ ⚠️ **Never** pass sudo passwords directly in commands. Instead:
113
+
114
+ **Option A: Configure in .env (Recommended)**
115
+ ```env
116
+ SSH_SERVER_PRODUCTION_SUDO_PASSWORD=your_password
117
+ ```
118
+
119
+ **Option B: Use key-based sudo (Most Secure)**
120
+ Configure passwordless sudo for specific commands on your server.
121
+
122
+ ### 2. Sensitive File Handling
123
+
124
+ The deployment tool automatically:
125
+ - Never logs passwords in output
126
+ - Masks sensitive information in logs
127
+ - Uses secure temp file locations
128
+
129
+ ### 3. Backup Strategy
130
+
131
+ Always enabled by default:
132
+ - Creates timestamped backups before overwriting
133
+ - Format: `original_file.bak.YYYYMMDD_HHMMSS`
134
+
135
+ ## Troubleshooting
136
+
137
+ ### Permission Denied Errors
138
+
139
+ **Problem**: Can't write to system directories
140
+
141
+ **Solution**: Use `ssh_deploy` with proper options:
142
+ ```json
143
+ {
144
+ "options": {
145
+ "owner": "www-data:www-data",
146
+ "sudoPassword": "configured_in_env"
147
+ }
148
+ }
149
+ ```
150
+
151
+ ### Server Not Found
152
+
153
+ **Problem**: "Server 'dmis.neoffice.me' not found"
154
+
155
+ **Solution**: Use configured name or create an alias:
156
+ ```
157
+ "Create alias 'dmis.neoffice.me' for dmis"
158
+ ```
159
+
160
+ ### Files Not Updating
161
+
162
+ **Problem**: Files uploaded but changes not visible
163
+
164
+ **Solution**: Ensure service restart:
165
+ ```json
166
+ {
167
+ "options": {
168
+ "restart": "bench restart"
169
+ }
170
+ }
171
+ ```
172
+
173
+ ## Configuration Examples
174
+
175
+ ### .env Configuration
176
+
177
+ ```env
178
+ # Server with sudo password for deployments
179
+ SSH_SERVER_PRODUCTION_HOST=prod.example.com
180
+ SSH_SERVER_PRODUCTION_USER=deploy
181
+ SSH_SERVER_PRODUCTION_PASSWORD=deploy_password
182
+ SSH_SERVER_PRODUCTION_SUDO_PASSWORD=sudo_password
183
+ SSH_SERVER_PRODUCTION_DEFAULT_DIR=/var/www/app
184
+
185
+ # Development server with key auth
186
+ SSH_SERVER_DEV_HOST=dev.example.com
187
+ SSH_SERVER_DEV_USER=developer
188
+ SSH_SERVER_DEV_KEYPATH=~/.ssh/dev_key
189
+ SSH_SERVER_DEV_DEFAULT_DIR=/home/developer/app
190
+ ```
191
+
192
+ ### Alias Configuration
193
+
194
+ Create a `.server-aliases.json`:
195
+
196
+ ```json
197
+ {
198
+ "prod": "production",
199
+ "dev": "development",
200
+ "stage": "staging",
201
+ "dmis": "dmis_server"
202
+ }
203
+ ```
204
+
205
+ ## Performance Tips
206
+
207
+ 1. **Batch Deployments**: Deploy multiple files in one command
208
+ 2. **Use Aliases**: Shorter names = faster typing
209
+ 3. **Default Directories**: Set default dirs to avoid repetition
210
+ 4. **Connection Reuse**: Connections are kept alive during session
211
+
212
+ ## Example: Complete ERPNext Update
213
+
214
+ Based on your real scenario, here's the optimized workflow:
215
+
216
+ ```bash
217
+ # 1. Setup (one time)
218
+ "Create alias 'dmis' for dmis server"
219
+
220
+ # 2. Deploy both files at once
221
+ "Deploy these files to dmis:
222
+ - payment_proposal.py to /home/neoffice/frappe-bench/apps/erpnextswiss/erpnextswiss/doctype/payment_proposal/
223
+ - payment_proposal.js to same location"
224
+
225
+ # 3. Restart service
226
+ "Run 'cd /home/neoffice/frappe-bench && bench restart' on dmis"
227
+ ```
228
+
229
+ This replaces your previous multi-step process:
230
+ - ❌ Upload to wrong location
231
+ - ❌ Permission errors
232
+ - ❌ Manual sudo password entry
233
+ - ❌ Copy from /tmp
234
+ - ✅ Single command deployment!
235
+
236
+ ## Support
237
+
238
+ For issues or questions:
239
+ - Check server logs: `"Execute 'tail -f /var/log/syslog' on server"`
240
+ - Test connection: `python tools/test-connection.py servername`
241
+ - View aliases: `"List server aliases"`
package/docs/SEO.md ADDED
@@ -0,0 +1,257 @@
1
+ # MCP SSH - Complete Guide to SSH Management via Model Context Protocol
2
+
3
+ This is the comprehensive guide for **MCP SSH Manager**, the leading Model Context Protocol (MCP) server for SSH remote server management.
4
+
5
+ ## What is MCP SSH?
6
+
7
+ **MCP SSH Manager** is a complete **Model Context Protocol (MCP) server** that enables SSH remote server management directly from AI assistants like **Claude Code** and **OpenAI Codex**. It's the most comprehensive **SSH MCP** solution available, offering 37+ MCP tools for complete remote server control.
8
+
9
+ ### Why MCP SSH Manager?
10
+
11
+ If you're searching for:
12
+ - **MCP SSH** server
13
+ - **SSH MCP** integration
14
+ - **Model Context Protocol SSH** tools
15
+ - **Claude Code SSH** support
16
+ - **OpenAI Codex SSH** compatibility
17
+ - **Remote SSH MCP** server
18
+ - **SSH automation with AI**
19
+
20
+ Then **MCP SSH Manager** is exactly what you need! 🎯
21
+
22
+ ## MCP SSH vs Traditional SSH
23
+
24
+ Traditional SSH requires manual terminal commands and script writing. With **MCP SSH Manager**, you can:
25
+
26
+ 1. **Natural Language Control**: "Deploy my app to production" instead of writing deployment scripts
27
+ 2. **AI-Powered Automation**: Let Claude Code or Codex handle complex SSH operations
28
+ 3. **Multi-Server Management**: Control multiple SSH servers from a single interface
29
+ 4. **Enterprise Features**: Backup, restore, health monitoring, database management
30
+ 5. **Zero Learning Curve**: Just ask your AI assistant what you want to do
31
+
32
+ ## How to Use MCP SSH with Claude Code
33
+
34
+ ### Quick Installation
35
+
36
+ ```bash
37
+ git clone https://github.com/bvisible/mcp-ssh-manager.git
38
+ cd mcp-ssh-manager
39
+ npm install
40
+ claude mcp add ssh-manager node /path/to/mcp-ssh-manager/src/index.js
41
+ ```
42
+
43
+ ### Natural Language SSH Commands
44
+
45
+ Once installed, simply ask Claude Code:
46
+
47
+ - "List my SSH servers"
48
+ - "Execute 'docker ps' on production"
49
+ - "Backup production database"
50
+ - "Monitor CPU usage on all servers"
51
+ - "Deploy files to staging server"
52
+ - "Check health of production server"
53
+
54
+ ## How to Use SSH MCP with OpenAI Codex
55
+
56
+ ### Codex Integration
57
+
58
+ ```bash
59
+ ssh-manager codex setup
60
+ ssh-manager codex migrate
61
+ ```
62
+
63
+ Configure in `~/.codex/config.toml`:
64
+
65
+ ```toml
66
+ [mcp_servers.ssh-manager]
67
+ command = "node"
68
+ args = ["/path/to/mcp-ssh-manager/src/index.js"]
69
+ env = { SSH_CONFIG_PATH = "/Users/you/.codex/ssh-config.toml" }
70
+ ```
71
+
72
+ ## MCP SSH Features
73
+
74
+ ### Core SSH MCP Features
75
+
76
+ 1. **SSH Command Execution** - Run any command on remote servers via MCP
77
+ 2. **File Transfer** - Upload/download files through the MCP protocol
78
+ 3. **Server Management** - List, configure, and manage SSH connections
79
+ 4. **Persistent Sessions** - Maintain SSH context across multiple commands
80
+
81
+ ### Enterprise SSH MCP Features
82
+
83
+ 1. **Database Management** (MCP SSH DB tools)
84
+ - MySQL, PostgreSQL, MongoDB support
85
+ - Safe query execution via MCP
86
+ - Database dumps and imports
87
+ - Schema exploration
88
+
89
+ 2. **Backup & Restore** (MCP SSH Backup)
90
+ - Automated backup scheduling
91
+ - Database and file backups
92
+ - One-click restore via MCP
93
+ - Retention policies
94
+
95
+ 3. **Health Monitoring** (MCP SSH Monitor)
96
+ - Real-time server health checks
97
+ - Service status monitoring
98
+ - Process management
99
+ - Alert thresholds
100
+
101
+ 4. **Smart Deployment** (MCP SSH Deploy)
102
+ - Automated deployments via MCP
103
+ - Permission handling
104
+ - Rollback support
105
+ - Multi-server deployment
106
+
107
+ ## Model Context Protocol (MCP) for SSH
108
+
109
+ The **Model Context Protocol (MCP)** is a standardized way for AI assistants to interact with external tools and services. **MCP SSH Manager** implements the MCP specification to provide:
110
+
111
+ - **37+ MCP Tools** for SSH operations
112
+ - **Type-safe** SSH operations via MCP schemas
113
+ - **Secure** credential management
114
+ - **Standardized** interface for all AI assistants
115
+ - **Extensible** architecture for custom SSH workflows
116
+
117
+ ## SSH MCP Tools Reference
118
+
119
+ ### Core MCP SSH Tools
120
+
121
+ - `ssh_execute` - Execute SSH commands via MCP
122
+ - `ssh_upload` - Upload files through MCP SSH
123
+ - `ssh_download` - Download files via MCP SSH
124
+ - `ssh_list_servers` - List SSH servers in MCP
125
+
126
+ ### Advanced MCP SSH Tools
127
+
128
+ - `ssh_backup_create` - Create backups via MCP SSH
129
+ - `ssh_health_check` - Health monitoring through MCP
130
+ - `ssh_db_dump` - Database operations via MCP SSH
131
+ - `ssh_deploy` - Smart deployment through MCP
132
+ - `ssh_tunnel_create` - SSH tunnels via MCP
133
+ - `ssh_sync` - File synchronization through MCP SSH
134
+
135
+ [See full list in README.md](../README.md#-available-mcp-tools)
136
+
137
+ ## MCP SSH Configuration
138
+
139
+ ### For Claude Code (Environment Variables)
140
+
141
+ ```env
142
+ SSH_SERVER_PROD_HOST=prod.example.com
143
+ SSH_SERVER_PROD_USER=admin
144
+ SSH_SERVER_PROD_KEYPATH=~/.ssh/prod_key
145
+ ```
146
+
147
+ ### For OpenAI Codex (TOML Format)
148
+
149
+ ```toml
150
+ [ssh_servers.production]
151
+ host = "prod.example.com"
152
+ user = "admin"
153
+ key_path = "~/.ssh/prod_key"
154
+ ```
155
+
156
+ ## SSH MCP Use Cases
157
+
158
+ ### DevOps Automation with MCP SSH
159
+
160
+ - Automated deployments to remote servers
161
+ - Database backup and restore workflows
162
+ - Server health monitoring and alerting
163
+ - Log analysis and troubleshooting
164
+ - Multi-server configuration management
165
+
166
+ ### Development Workflows with SSH MCP
167
+
168
+ - Remote development environment setup
169
+ - Code deployment to staging/production
170
+ - Database migration management
171
+ - Service restart and monitoring
172
+ - Debug log collection
173
+
174
+ ### Database Administration via MCP SSH
175
+
176
+ - Backup scheduling and management
177
+ - Database dumps and imports
178
+ - Query execution and analysis
179
+ - Schema inspection
180
+ - Cross-server data migration
181
+
182
+ ## MCP SSH Security
183
+
184
+ **MCP SSH Manager** implements multiple security layers:
185
+
186
+ 1. **Credential Protection** - Never exposes SSH credentials to AI
187
+ 2. **Command Validation** - Validates all SSH commands before execution
188
+ 3. **SQL Injection Prevention** - Only allows safe database queries
189
+ 4. **Audit Logging** - Tracks all SSH operations via MCP
190
+ 5. **Connection Pooling** - Secure connection management
191
+
192
+ ## Troubleshooting MCP SSH
193
+
194
+ ### MCP SSH Not Found
195
+
196
+ If "mcp ssh" searches don't show this project:
197
+
198
+ 1. Star this repository on GitHub
199
+ 2. Share with the MCP community
200
+ 3. Add topics to your repository
201
+ 4. Link to this project in your documentation
202
+
203
+ ### MCP SSH Connection Issues
204
+
205
+ 1. Test connection: `ssh-manager server test [name]`
206
+ 2. Verify SSH credentials
207
+ 3. Check firewall rules
208
+ 4. Review MCP server logs
209
+
210
+ ### Claude Code SSH Integration
211
+
212
+ 1. Verify installation: `claude mcp list`
213
+ 2. Restart Claude Code
214
+ 3. Check MCP configuration
215
+ 4. Test with simple command
216
+
217
+ ## MCP SSH Community
218
+
219
+ ### Contributing to MCP SSH
220
+
221
+ We welcome contributions to **MCP SSH Manager**! See [CONTRIBUTING.md](../CONTRIBUTING.md) for details.
222
+
223
+ ### MCP SSH Support
224
+
225
+ - GitHub Issues: [Report bugs](https://github.com/bvisible/mcp-ssh-manager/issues)
226
+ - Documentation: [Full docs](../README.md)
227
+ - Examples: [Example workflows](../examples/)
228
+
229
+ ## MCP SSH Alternatives
230
+
231
+ While there are other SSH tools and MCP servers, **MCP SSH Manager** offers:
232
+
233
+ - ✅ Most comprehensive SSH MCP tool collection (37+ tools)
234
+ - ✅ Both Claude Code AND OpenAI Codex support
235
+ - ✅ Enterprise features (backup, monitoring, database)
236
+ - ✅ Active development and support
237
+ - ✅ Open source MIT license
238
+ - ✅ Production-ready and battle-tested
239
+
240
+ ## Conclusion
241
+
242
+ **MCP SSH Manager** is the definitive **Model Context Protocol** solution for **SSH remote server management**. Whether you're using **Claude Code** or **OpenAI Codex**, this **MCP SSH** server provides everything you need for AI-powered SSH automation.
243
+
244
+ **Get started today:**
245
+ ```bash
246
+ git clone https://github.com/bvisible/mcp-ssh-manager.git
247
+ cd mcp-ssh-manager
248
+ npm install
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Keywords for Search
254
+
255
+ This document covers: MCP SSH, SSH MCP, Model Context Protocol SSH, MCP SSH Manager, Claude Code SSH, OpenAI Codex SSH, SSH MCP Server, Remote SSH MCP, MCP Server SSH, SSH automation MCP, AI SSH tools, SSH Model Context Protocol, MCP SSH integration, SSH management MCP, MCP remote server, SSH DevOps MCP, MCP SSH backup, MCP SSH monitoring, MCP SSH database, SSH orchestration MCP.
256
+
257
+ **Repository**: [https://github.com/bvisible/mcp-ssh-manager](https://github.com/bvisible/mcp-ssh-manager)