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,284 @@
1
+ #!/bin/bash
2
+ # Server management commands for ssh-manager CLI
3
+
4
+ # Add a new server
5
+ cmd_server_add() {
6
+ print_header "Add New SSH Server"
7
+
8
+ # Get server name
9
+ local server_name
10
+ while true; do
11
+ prompt_input "Server name (e.g., prod1, web-server)" "" "server_name"
12
+ if validate_server_name "$server_name"; then
13
+ break
14
+ fi
15
+ done
16
+
17
+ # Get host
18
+ local host
19
+ prompt_input "Host/IP address" "" "host"
20
+
21
+ # Get username
22
+ local user
23
+ prompt_input "Username" "root" "user"
24
+
25
+ # Get port
26
+ local port
27
+ prompt_input "Port" "22" "port"
28
+
29
+ # Get authentication type
30
+ echo -e "\nAuthentication method:"
31
+ echo " 1) SSH Key"
32
+ echo " 2) Password"
33
+ read -p "Choose [1-2]: " auth_choice
34
+
35
+ local auth_type auth_value
36
+ case "$auth_choice" in
37
+ 2)
38
+ auth_type="password"
39
+ prompt_password "Password" "auth_value"
40
+ ;;
41
+ *)
42
+ auth_type="key"
43
+ prompt_input "SSH key path" "$HOME/.ssh/id_rsa" "auth_value"
44
+ # Expand ~ to home directory
45
+ auth_value="${auth_value/#\~/$HOME}"
46
+ ;;
47
+ esac
48
+
49
+ # Get optional description
50
+ local description
51
+ prompt_input "Description (optional)" "" "description"
52
+
53
+ # Show summary
54
+ echo
55
+ print_subheader "Configuration Summary"
56
+ print_table_row "Name:" "$server_name"
57
+ print_table_row "Host:" "$host"
58
+ print_table_row "User:" "$user"
59
+ print_table_row "Port:" "$port"
60
+ print_table_row "Auth:" "$auth_type"
61
+ if [ "$auth_type" = "key" ]; then
62
+ print_table_row "Key:" "$auth_value"
63
+ fi
64
+ if [ -n "$description" ]; then
65
+ print_table_row "Description:" "$description"
66
+ fi
67
+
68
+ echo
69
+ if prompt_yes_no "Save this configuration?" "y"; then
70
+ add_server_to_env "$server_name" "$host" "$user" "$auth_type" "$auth_value" "$port" "$description"
71
+
72
+ echo
73
+ if prompt_yes_no "Test connection now?" "y"; then
74
+ test_ssh_connection "$server_name"
75
+ fi
76
+ else
77
+ print_info "Server configuration cancelled"
78
+ fi
79
+ }
80
+
81
+ # List all servers
82
+ cmd_server_list() {
83
+ print_header "SSH Servers"
84
+
85
+ local servers=($(load_servers))
86
+
87
+ if [ ${#servers[@]} -eq 0 ]; then
88
+ print_warning "No servers configured"
89
+ print_info "Use 'ssh-manager server add' to add a server"
90
+ return 0
91
+ fi
92
+
93
+ print_table_header "NAME" "HOST" "USER"
94
+
95
+ for server in "${servers[@]}"; do
96
+ local host=$(get_server_config "$server" "HOST")
97
+ local user=$(get_server_config "$server" "USER")
98
+ local port=$(get_server_config "$server" "PORT")
99
+ local description=$(get_server_config "$server" "DESCRIPTION")
100
+
101
+ port=${port:-22}
102
+
103
+ local host_info="$host:$port"
104
+ if [ -n "$description" ]; then
105
+ host_info="$host_info ($description)"
106
+ fi
107
+
108
+ print_table_row "$server" "$host_info" "$user"
109
+ done
110
+
111
+ echo
112
+ print_info "Total servers: ${#servers[@]}"
113
+ }
114
+
115
+ # Test server connection
116
+ cmd_server_test() {
117
+ local server="$1"
118
+
119
+ if [ -z "$server" ]; then
120
+ # Show menu if no server specified
121
+ print_header "Test SSH Connection"
122
+
123
+ local servers=($(load_servers))
124
+ if [ ${#servers[@]} -eq 0 ]; then
125
+ print_warning "No servers configured"
126
+ return 1
127
+ fi
128
+
129
+ echo "Select a server to test:"
130
+ local i=1
131
+ for s in "${servers[@]}"; do
132
+ echo " $i) $s"
133
+ ((i++))
134
+ done
135
+
136
+ read -p "Choose [1-${#servers[@]}]: " choice
137
+ if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le ${#servers[@]} ]; then
138
+ server="${servers[$((choice-1))]}"
139
+ else
140
+ print_error "Invalid choice"
141
+ return 1
142
+ fi
143
+ fi
144
+
145
+ test_ssh_connection "$server"
146
+ }
147
+
148
+ # Remove a server
149
+ cmd_server_remove() {
150
+ local server="$1"
151
+
152
+ if [ -z "$server" ]; then
153
+ # Show menu if no server specified
154
+ print_header "Remove SSH Server"
155
+
156
+ local servers=($(load_servers))
157
+ if [ ${#servers[@]} -eq 0 ]; then
158
+ print_warning "No servers configured"
159
+ return 1
160
+ fi
161
+
162
+ echo "Select a server to remove:"
163
+ local i=1
164
+ for s in "${servers[@]}"; do
165
+ local host=$(get_server_config "$s" "HOST")
166
+ echo " $i) $s ($host)"
167
+ ((i++))
168
+ done
169
+
170
+ read -p "Choose [1-${#servers[@]}]: " choice
171
+ if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le ${#servers[@]} ]; then
172
+ server="${servers[$((choice-1))]}"
173
+ else
174
+ print_error "Invalid choice"
175
+ return 1
176
+ fi
177
+ fi
178
+
179
+ local host=$(get_server_config "$server" "HOST")
180
+ if [ -z "$host" ]; then
181
+ print_error "Server '$server' not found"
182
+ return 1
183
+ fi
184
+
185
+ echo
186
+ print_warning "This will remove server '$server' ($host)"
187
+ if prompt_yes_no "Are you sure?" "n"; then
188
+ remove_server_from_env "$server"
189
+ else
190
+ print_info "Removal cancelled"
191
+ fi
192
+ }
193
+
194
+ # Edit server configuration
195
+ cmd_server_edit() {
196
+ local editor=$(get_config "default_editor" "${EDITOR:-nano}")
197
+
198
+ if [ ! -f "$SSH_MANAGER_ENV" ]; then
199
+ print_error "Configuration file not found: $SSH_MANAGER_ENV"
200
+ return 1
201
+ fi
202
+
203
+ print_info "Opening configuration in $editor..."
204
+ $editor "$SSH_MANAGER_ENV"
205
+
206
+ print_success "Configuration updated"
207
+ }
208
+
209
+ # Show server details
210
+ cmd_server_show() {
211
+ local server="$1"
212
+
213
+ if [ -z "$server" ]; then
214
+ print_error "Server name required"
215
+ return 1
216
+ fi
217
+
218
+ local host=$(get_server_config "$server" "HOST")
219
+ if [ -z "$host" ]; then
220
+ print_error "Server '$server' not found"
221
+ return 1
222
+ fi
223
+
224
+ print_header "Server Details: $server"
225
+
226
+ print_table_row "Host:" "$host"
227
+ print_table_row "User:" "$(get_server_config "$server" "USER")"
228
+ print_table_row "Port:" "$(get_server_config "$server" "PORT")"
229
+
230
+ local keypath=$(get_server_config "$server" "KEYPATH")
231
+ local password=$(get_server_config "$server" "PASSWORD")
232
+
233
+ if [ -n "$keypath" ]; then
234
+ print_table_row "Auth Type:" "SSH Key"
235
+ print_table_row "Key Path:" "$keypath"
236
+ elif [ -n "$password" ]; then
237
+ print_table_row "Auth Type:" "Password"
238
+ print_table_row "Password:" "********"
239
+ else
240
+ print_table_row "Auth Type:" "Unknown"
241
+ fi
242
+
243
+ local description=$(get_server_config "$server" "DESCRIPTION")
244
+ if [ -n "$description" ]; then
245
+ print_table_row "Description:" "$description"
246
+ fi
247
+
248
+ local default_dir=$(get_server_config "$server" "DEFAULT_DIR")
249
+ if [ -n "$default_dir" ]; then
250
+ print_table_row "Default Dir:" "$default_dir"
251
+ fi
252
+ }
253
+
254
+ # Main server command handler
255
+ cmd_server() {
256
+ local subcommand="$1"
257
+ shift
258
+
259
+ case "$subcommand" in
260
+ add)
261
+ cmd_server_add "$@"
262
+ ;;
263
+ list|ls)
264
+ cmd_server_list "$@"
265
+ ;;
266
+ test)
267
+ cmd_server_test "$@"
268
+ ;;
269
+ remove|rm)
270
+ cmd_server_remove "$@"
271
+ ;;
272
+ edit)
273
+ cmd_server_edit "$@"
274
+ ;;
275
+ show|info)
276
+ cmd_server_show "$@"
277
+ ;;
278
+ *)
279
+ print_error "Unknown server command: $subcommand"
280
+ echo "Available commands: add, list, test, remove, edit, show"
281
+ return 1
282
+ ;;
283
+ esac
284
+ }
package/cli/demo.sh ADDED
@@ -0,0 +1,107 @@
1
+ #!/bin/bash
2
+ # Demo script to showcase the SSH Manager CLI interactive interface
3
+
4
+ # Colors
5
+ GREEN='\033[0;32m'
6
+ YELLOW='\033[1;33m'
7
+ BLUE='\033[0;34m'
8
+ CYAN='\033[0;36m'
9
+ NC='\033[0m'
10
+
11
+ clear
12
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
13
+ echo -e "${CYAN} SSH Manager CLI - Interactive Demo${NC}"
14
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
15
+ echo
16
+
17
+ echo -e "${GREEN}✨ Welcome to SSH Manager CLI!${NC}"
18
+ echo
19
+ echo "This demo will show you the key features of the interactive interface."
20
+ echo
21
+
22
+ echo -e "${YELLOW}📋 Main Features:${NC}"
23
+ echo " • Interactive menu with numbered choices"
24
+ echo " • Guided server setup wizard"
25
+ echo " • Server management (add, list, test, remove)"
26
+ echo " • Quick SSH connections"
27
+ echo " • File synchronization"
28
+ echo " • SSH tunnel creation"
29
+ echo " • System monitoring"
30
+ echo
31
+
32
+ echo -e "${YELLOW}🚀 To start the interactive mode, run:${NC}"
33
+ echo
34
+ echo " ssh-manager"
35
+ echo " ssh-manager -i"
36
+ echo " ssh-manager --interactive"
37
+ echo
38
+
39
+ echo -e "${YELLOW}📝 The interactive mode will show you:${NC}"
40
+ echo
41
+ echo " 1. Main menu with 8 options"
42
+ echo " 2. Server management submenu"
43
+ echo " 3. Guided wizards for complex tasks"
44
+ echo " 4. Server selection menus"
45
+ echo " 5. Real-time feedback with colors and emojis"
46
+ echo
47
+
48
+ echo -e "${YELLOW}🎯 Example: Adding a Server${NC}"
49
+ echo
50
+ echo "When you choose 'Server Management' → 'Add New Server', you'll get:"
51
+ echo " • Step-by-step wizard"
52
+ echo " • Input validation"
53
+ echo " • Clear examples for each field"
54
+ echo " • Review before saving"
55
+ echo " • Option to test connection"
56
+ echo
57
+
58
+ echo -e "${YELLOW}💡 Tips:${NC}"
59
+ echo " • Press 0 to go back in any menu"
60
+ echo " • Press Ctrl+C to exit anytime"
61
+ echo " • All configurations are saved in .env file"
62
+ echo " • Compatible with MCP server"
63
+ echo
64
+
65
+ read -p "Press Enter to see the main menu preview..."
66
+ echo
67
+
68
+ cat << 'EOF'
69
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
70
+ SSH Manager CLI v2.0.0
71
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
72
+
73
+ 1) 🖥️ Server Management
74
+ Add, list, test, and manage SSH servers
75
+
76
+ 2) 💻 Quick Connect
77
+ Connect to a server via SSH
78
+
79
+ 3) 🔄 File Synchronization
80
+ Push/pull files with rsync
81
+
82
+ 4) 🔧 SSH Tunnels
83
+ Create and manage SSH tunnels
84
+
85
+ 5) 📊 System Monitoring
86
+ Monitor server resources
87
+
88
+ 6) 🚀 Execute Commands
89
+ Run commands on servers
90
+
91
+ 7) ⚙️ Configuration
92
+ Edit settings and preferences
93
+
94
+ 8) ℹ️ Help & Documentation
95
+ View help and examples
96
+
97
+ 0) Exit
98
+
99
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
100
+ Choose an option [0-8]: _
101
+ EOF
102
+
103
+ echo
104
+ echo -e "${GREEN}✅ Ready to try it yourself!${NC}"
105
+ echo
106
+ echo "Run: ssh-manager"
107
+ echo
package/cli/install.sh ADDED
@@ -0,0 +1,164 @@
1
+ #!/bin/bash
2
+ # Installation script for SSH Manager CLI
3
+
4
+ set -e
5
+
6
+ # Colors
7
+ RED='\033[0;31m'
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ BLUE='\033[0;34m'
11
+ NC='\033[0m' # No Color
12
+
13
+ # Installation directory
14
+ INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
15
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
16
+
17
+ echo -e "${BLUE}SSH Manager CLI Installation${NC}"
18
+ echo "=============================="
19
+ echo
20
+
21
+ # Check for required dependencies
22
+ echo -e "${YELLOW}Checking dependencies...${NC}"
23
+ missing=()
24
+
25
+ for cmd in ssh rsync; do
26
+ if command -v "$cmd" >/dev/null 2>&1; then
27
+ echo -e " ${GREEN}✓${NC} $cmd"
28
+ else
29
+ echo -e " ${RED}✗${NC} $cmd (required)"
30
+ missing+=("$cmd")
31
+ fi
32
+ done
33
+
34
+ for cmd in jq sshpass; do
35
+ if command -v "$cmd" >/dev/null 2>&1; then
36
+ echo -e " ${GREEN}✓${NC} $cmd"
37
+ else
38
+ echo -e " ${YELLOW}⚠${NC} $cmd (optional)"
39
+ fi
40
+ done
41
+
42
+ if [ ${#missing[@]} -gt 0 ]; then
43
+ echo
44
+ echo -e "${RED}Error: Missing required dependencies: ${missing[*]}${NC}"
45
+ echo "Please install them and try again."
46
+ exit 1
47
+ fi
48
+
49
+ # Check installation directory
50
+ echo
51
+ echo -e "${YELLOW}Installation directory:${NC} $INSTALL_DIR"
52
+
53
+ if [ ! -w "$INSTALL_DIR" ]; then
54
+ echo -e "${YELLOW}Note: You may need sudo permissions to install to $INSTALL_DIR${NC}"
55
+ SUDO="sudo"
56
+ else
57
+ SUDO=""
58
+ fi
59
+
60
+ # Create symlink
61
+ echo
62
+ echo -e "${YELLOW}Installing ssh-manager...${NC}"
63
+
64
+ # Copy entire CLI directory to home
65
+ CLI_HOME="$HOME/.ssh-manager-cli"
66
+ echo "Copying CLI files to $CLI_HOME..."
67
+ rm -rf "$CLI_HOME"
68
+ cp -r "$SCRIPT_DIR" "$CLI_HOME"
69
+
70
+ # Create executable symlink
71
+ $SUDO ln -sf "$CLI_HOME/ssh-manager" "$INSTALL_DIR/ssh-manager"
72
+
73
+ # Make sure it's executable
74
+ chmod +x "$CLI_HOME/ssh-manager"
75
+
76
+ # Verify installation
77
+ if command -v ssh-manager >/dev/null 2>&1; then
78
+ echo
79
+ echo -e "${GREEN}✅ Installation successful!${NC}"
80
+ echo
81
+ echo "SSH Manager CLI has been installed to: $INSTALL_DIR/ssh-manager"
82
+ echo
83
+ echo "Quick start:"
84
+ echo " ssh-manager --help # Show help"
85
+ echo " ssh-manager server add # Add a new server"
86
+ echo " ssh-manager server list # List servers"
87
+ echo " ssh-manager server test # Test connection"
88
+ echo
89
+ echo "Configuration files:"
90
+ echo " ~/.ssh-manager/ # Config directory"
91
+ echo " .env # Server definitions"
92
+ else
93
+ echo
94
+ echo -e "${RED}❌ Installation failed${NC}"
95
+ echo "Please check the error messages above."
96
+ exit 1
97
+ fi
98
+
99
+ # Optional: Install shell completions
100
+ echo
101
+ read -p "Install bash completions? [y/N]: " install_completions
102
+ if [[ "$install_completions" =~ ^[yY]$ ]]; then
103
+ # Create bash completion script
104
+ cat > "$CLI_HOME/ssh-manager-completion.bash" <<'EOF'
105
+ # Bash completion for ssh-manager
106
+ _ssh_manager() {
107
+ local cur prev opts
108
+ COMPREPLY=()
109
+ cur="${COMP_WORDS[COMP_CWORD]}"
110
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
111
+
112
+ # Main commands
113
+ local commands="server sync tunnel monitor session exec config ssh help version"
114
+
115
+ # Server subcommands
116
+ local server_commands="add list test remove edit show"
117
+
118
+ # Sync subcommands
119
+ local sync_commands="push pull"
120
+
121
+ # Tunnel subcommands
122
+ local tunnel_commands="create list"
123
+
124
+ case "${COMP_CWORD}" in
125
+ 1)
126
+ COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
127
+ ;;
128
+ 2)
129
+ case "${prev}" in
130
+ server)
131
+ COMPREPLY=( $(compgen -W "${server_commands}" -- ${cur}) )
132
+ ;;
133
+ sync)
134
+ COMPREPLY=( $(compgen -W "${sync_commands}" -- ${cur}) )
135
+ ;;
136
+ tunnel)
137
+ COMPREPLY=( $(compgen -W "${tunnel_commands}" -- ${cur}) )
138
+ ;;
139
+ esac
140
+ ;;
141
+ esac
142
+
143
+ return 0
144
+ }
145
+
146
+ complete -F _ssh_manager ssh-manager
147
+ EOF
148
+
149
+ # Install to bash completion directory
150
+ if [ -d "/usr/local/etc/bash_completion.d" ]; then
151
+ $SUDO cp "$CLI_HOME/ssh-manager-completion.bash" "/usr/local/etc/bash_completion.d/"
152
+ echo -e "${GREEN}✓ Bash completions installed${NC}"
153
+ elif [ -d "/etc/bash_completion.d" ]; then
154
+ $SUDO cp "$CLI_HOME/ssh-manager-completion.bash" "/etc/bash_completion.d/"
155
+ echo -e "${GREEN}✓ Bash completions installed${NC}"
156
+ else
157
+ echo -e "${YELLOW}⚠ Could not find bash completion directory${NC}"
158
+ echo "Add this to your ~/.bashrc:"
159
+ echo " source $CLI_HOME/ssh-manager-completion.bash"
160
+ fi
161
+ fi
162
+
163
+ echo
164
+ echo -e "${GREEN}Installation complete! 🎉${NC}"