mcp-ssh-manager 3.4.1 → 3.5.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.
- package/.hooks-config.json +1 -1
- package/CHANGELOG.md +21 -0
- package/README.md +22 -0
- package/cli/commands/server.sh +34 -3
- package/cli/lib/config.sh +25 -6
- package/cli/migrate.sh +1 -1
- package/docs/ALIASES_AND_HOOKS.md +3 -3
- package/docs/DEPLOYMENT_GUIDE.md +23 -22
- package/docs/SECURITY_MODES.md +189 -0
- package/examples/deploy-workflow.py +48 -48
- package/package.json +3 -2
- package/src/audit.js +97 -0
- package/src/config-loader.js +82 -0
- package/src/index.js +135 -3
- package/src/policy.js +247 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
Example deployment workflow using MCP SSH Manager
|
|
4
|
-
|
|
3
|
+
Example deployment workflow using MCP SSH Manager.
|
|
4
|
+
|
|
5
|
+
These examples show three common deployment scenarios with the ssh_deploy
|
|
6
|
+
tool. All names (servers, paths, owners) are generic placeholders — adapt
|
|
7
|
+
them to your own infrastructure.
|
|
5
8
|
"""
|
|
6
9
|
|
|
7
10
|
import os
|
|
@@ -25,48 +28,45 @@ def create_deployment_config(server_name, files, options=None):
|
|
|
25
28
|
}
|
|
26
29
|
return config
|
|
27
30
|
|
|
28
|
-
def
|
|
31
|
+
def deploy_python_app_customization():
|
|
29
32
|
"""
|
|
30
|
-
Example:
|
|
31
|
-
|
|
33
|
+
Example: deploy two files of a Python application into a target install.
|
|
34
|
+
Replace the local/remote paths and the server alias with your own values.
|
|
32
35
|
"""
|
|
33
|
-
|
|
34
|
-
# Define the files to deploy
|
|
36
|
+
|
|
35
37
|
files_to_deploy = [
|
|
36
38
|
{
|
|
37
|
-
"local": "/
|
|
38
|
-
"remote": "/
|
|
39
|
+
"local": "./build/myapp/module/handler.py",
|
|
40
|
+
"remote": "/opt/myapp/apps/myapp/module/handler.py"
|
|
39
41
|
},
|
|
40
42
|
{
|
|
41
|
-
"local": "/
|
|
42
|
-
"remote": "/
|
|
43
|
+
"local": "./build/myapp/module/handler.js",
|
|
44
|
+
"remote": "/opt/myapp/apps/myapp/module/handler.js"
|
|
43
45
|
}
|
|
44
46
|
]
|
|
45
|
-
|
|
46
|
-
# Deployment options
|
|
47
|
+
|
|
47
48
|
options = {
|
|
48
|
-
"owner": "
|
|
49
|
-
"permissions": "644",
|
|
50
|
-
"backup": True,
|
|
51
|
-
"restart": "cd /
|
|
49
|
+
"owner": "appuser:appuser", # Set correct ownership
|
|
50
|
+
"permissions": "644", # Standard file permissions
|
|
51
|
+
"backup": True, # Always backup before overwriting
|
|
52
|
+
"restart": "cd /opt/myapp && ./bin/restart" # Restart hook
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
|
|
55
|
+
deployment = create_deployment_config("production", files_to_deploy, options)
|
|
56
|
+
|
|
57
57
|
print("📦 Deployment Configuration:")
|
|
58
58
|
print(json.dumps(deployment, indent=2))
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
# In Claude Code, you would say:
|
|
61
|
-
# "Deploy
|
|
62
|
-
|
|
61
|
+
# "Deploy handler files to production with appuser ownership and restart the app"
|
|
62
|
+
|
|
63
63
|
return deployment
|
|
64
64
|
|
|
65
65
|
def deploy_web_application():
|
|
66
66
|
"""
|
|
67
67
|
Example: Deploy web application files
|
|
68
68
|
"""
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
files_to_deploy = [
|
|
71
71
|
{
|
|
72
72
|
"local": "./dist/index.html",
|
|
@@ -81,26 +81,26 @@ def deploy_web_application():
|
|
|
81
81
|
"remote": "/var/www/html/css/styles.css"
|
|
82
82
|
}
|
|
83
83
|
]
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
options = {
|
|
86
86
|
"owner": "www-data:www-data",
|
|
87
87
|
"permissions": "644",
|
|
88
88
|
"backup": True,
|
|
89
89
|
"restart": "systemctl restart nginx"
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
deployment = create_deployment_config("production", files_to_deploy, options)
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
print("🌐 Web Deployment Configuration:")
|
|
95
95
|
print(json.dumps(deployment, indent=2))
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
return deployment
|
|
98
98
|
|
|
99
99
|
def deploy_configuration_files():
|
|
100
100
|
"""
|
|
101
101
|
Example: Deploy configuration files with elevated privileges
|
|
102
102
|
"""
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
files_to_deploy = [
|
|
105
105
|
{
|
|
106
106
|
"local": "./config/nginx.conf",
|
|
@@ -111,65 +111,65 @@ def deploy_configuration_files():
|
|
|
111
111
|
"remote": "/etc/myapp/app.env"
|
|
112
112
|
}
|
|
113
113
|
]
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
options = {
|
|
116
116
|
"owner": "root:root",
|
|
117
117
|
"permissions": "600", # Restrictive permissions for config files
|
|
118
118
|
"backup": True,
|
|
119
119
|
"restart": "systemctl reload nginx && systemctl restart myapp"
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
deployment = create_deployment_config("production", files_to_deploy, options)
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
print("⚙️ Configuration Deployment:")
|
|
125
125
|
print(json.dumps(deployment, indent=2))
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
return deployment
|
|
128
128
|
|
|
129
129
|
def main():
|
|
130
130
|
"""
|
|
131
131
|
Demonstrate various deployment scenarios
|
|
132
132
|
"""
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
print("🚀 MCP SSH Manager - Deployment Examples")
|
|
135
135
|
print("=" * 50)
|
|
136
136
|
print()
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
# Check if server configuration exists
|
|
139
139
|
servers = load_env_config()
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
if not servers:
|
|
142
142
|
print("⚠️ No servers configured. Run 'python tools/server_manager.py' to add servers.")
|
|
143
143
|
return
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
print("📋 Available servers:", ", ".join(servers.keys()))
|
|
146
146
|
print()
|
|
147
|
-
|
|
148
|
-
# Example 1:
|
|
149
|
-
print("Example 1:
|
|
147
|
+
|
|
148
|
+
# Example 1: Python application file deployment
|
|
149
|
+
print("Example 1: Python application customization deployment")
|
|
150
150
|
print("-" * 30)
|
|
151
|
-
|
|
151
|
+
deploy_python_app_customization()
|
|
152
152
|
print()
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
# Example 2: Web application deployment
|
|
155
155
|
print("Example 2: Web Application Deployment")
|
|
156
156
|
print("-" * 30)
|
|
157
157
|
deploy_web_application()
|
|
158
158
|
print()
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
# Example 3: Configuration files deployment
|
|
161
161
|
print("Example 3: Configuration Files Deployment")
|
|
162
162
|
print("-" * 30)
|
|
163
163
|
deploy_configuration_files()
|
|
164
164
|
print()
|
|
165
|
-
|
|
165
|
+
|
|
166
166
|
print("💡 Tips for using in Claude Code:")
|
|
167
167
|
print("-" * 30)
|
|
168
168
|
print("1. Create server aliases for easier access:")
|
|
169
|
-
print(' "Create alias
|
|
169
|
+
print(' "Create alias prod for production_server"')
|
|
170
170
|
print()
|
|
171
171
|
print("2. Deploy multiple files at once:")
|
|
172
|
-
print(' "Deploy all .py and .js files from
|
|
172
|
+
print(' "Deploy all .py and .js files from module/ to production"')
|
|
173
173
|
print()
|
|
174
174
|
print("3. Use sudo for system files:")
|
|
175
175
|
print(' "Deploy nginx.conf to production:/etc/nginx/ with sudo"')
|
|
@@ -180,4 +180,4 @@ def main():
|
|
|
180
180
|
print("📚 See docs/DEPLOYMENT_GUIDE.md for complete documentation")
|
|
181
181
|
|
|
182
182
|
if __name__ == "__main__":
|
|
183
|
-
main()
|
|
183
|
+
main()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "MCP SSH Manager: Model Context Protocol server for SSH remote server management. Control SSH connections from Claude Code and OpenAI Codex - execute commands, transfer files, database operations, backups, health monitoring, and DevOps automation. NEW: Tool activation system reduces context usage by 92%",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
14
14
|
"configure": "python tools/server-manager.py",
|
|
15
15
|
"test-connection": "python tools/test-connection.py",
|
|
16
|
-
"test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools",
|
|
16
|
+
"test": "npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy",
|
|
17
17
|
"test:profiles": "node tests/test-profiles.js",
|
|
18
18
|
"test:aliases": "node tests/test-command-aliases.js",
|
|
19
19
|
"test:hooks": "node tests/test-hooks.js",
|
|
20
20
|
"test:tools": "node tests/test-tool-registry.js",
|
|
21
|
+
"test:policy": "node tests/test-policy.js",
|
|
21
22
|
"test:all": "npm test && ./scripts/validate.sh",
|
|
22
23
|
"validate": "./scripts/validate.sh",
|
|
23
24
|
"lint": "eslint src/*.js",
|
package/src/audit.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-server append-only audit log.
|
|
3
|
+
*
|
|
4
|
+
* Activated only when a server's config has AUDIT_LOG (env) / audit_log (TOML)
|
|
5
|
+
* set to a writable file path. No-op otherwise — pre-v3.5.0 users see zero
|
|
6
|
+
* change.
|
|
7
|
+
*
|
|
8
|
+
* Output format: one JSON object per line (JSONL), to make the log greppable
|
|
9
|
+
* and consumable by log shippers (vector, fluentbit, etc.). Rotation is
|
|
10
|
+
* intentionally not handled here — use logrotate or equivalent.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { logger } from './logger.js';
|
|
16
|
+
|
|
17
|
+
// Field names whose values should never appear in the audit log even if a tool
|
|
18
|
+
// somehow passed them through args. Case-insensitive.
|
|
19
|
+
const REDACT_FIELDS = new Set([
|
|
20
|
+
'password',
|
|
21
|
+
'passphrase',
|
|
22
|
+
'sudopassword',
|
|
23
|
+
'sudo_password',
|
|
24
|
+
'token',
|
|
25
|
+
'secret',
|
|
26
|
+
'apikey',
|
|
27
|
+
'api_key',
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
const REDACTED = '***';
|
|
31
|
+
|
|
32
|
+
function sanitize(value) {
|
|
33
|
+
if (value === null || typeof value !== 'object') return value;
|
|
34
|
+
if (Array.isArray(value)) return value.map(sanitize);
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const [k, v] of Object.entries(value)) {
|
|
37
|
+
if (REDACT_FIELDS.has(k.toLowerCase())) {
|
|
38
|
+
out[k] = REDACTED;
|
|
39
|
+
} else {
|
|
40
|
+
out[k] = sanitize(v);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let warnedPaths = new Set();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Append one audit line. No-op if the server has no auditLog configured.
|
|
50
|
+
* Failures are logged but never propagated — auditing must not break tool execution.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} serverConfig
|
|
53
|
+
* @param {string} toolName
|
|
54
|
+
* @param {Object} args - tool arguments (will be sanitized)
|
|
55
|
+
* @param {Object} policyResult - { allowed, reason? } from evaluatePolicy
|
|
56
|
+
* @param {Object} [executionResult] - { code, success, error? } if the tool ran
|
|
57
|
+
*/
|
|
58
|
+
export function auditLog(serverConfig, toolName, args, policyResult, executionResult) {
|
|
59
|
+
if (!serverConfig || !serverConfig.auditLog) return;
|
|
60
|
+
|
|
61
|
+
const auditPath = serverConfig.auditLog;
|
|
62
|
+
const entry = {
|
|
63
|
+
ts: new Date().toISOString(),
|
|
64
|
+
server: serverConfig.name,
|
|
65
|
+
tool: toolName,
|
|
66
|
+
args: sanitize(args),
|
|
67
|
+
allowed: !!policyResult.allowed,
|
|
68
|
+
};
|
|
69
|
+
if (policyResult.reason) entry.reason = policyResult.reason;
|
|
70
|
+
if (executionResult) {
|
|
71
|
+
if (typeof executionResult.code === 'number') entry.exitCode = executionResult.code;
|
|
72
|
+
if (typeof executionResult.success === 'boolean') entry.success = executionResult.success;
|
|
73
|
+
if (executionResult.error) entry.error = String(executionResult.error).slice(0, 500);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const dir = path.dirname(auditPath);
|
|
78
|
+
if (dir && dir !== '.' && !fs.existsSync(dir)) {
|
|
79
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
80
|
+
}
|
|
81
|
+
fs.appendFileSync(auditPath, JSON.stringify(entry) + '\n', { encoding: 'utf8' });
|
|
82
|
+
} catch (err) {
|
|
83
|
+
// Warn once per path, then stay silent to avoid log spam if the path is
|
|
84
|
+
// permanently broken (e.g. read-only filesystem).
|
|
85
|
+
if (!warnedPaths.has(auditPath)) {
|
|
86
|
+
warnedPaths.add(auditPath);
|
|
87
|
+
logger.warn(
|
|
88
|
+
`Failed to write audit log for server "${serverConfig.name}" at ${auditPath}: ${err.message} (further failures for this path will be silenced)`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Exposed for tests.
|
|
95
|
+
export function _resetWarnedPaths() {
|
|
96
|
+
warnedPaths.clear();
|
|
97
|
+
}
|
package/src/config-loader.js
CHANGED
|
@@ -4,6 +4,33 @@ import fs from 'fs';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import os from 'os';
|
|
6
6
|
import { logger } from './logger.js';
|
|
7
|
+
import { VALID_MODES } from './policy.js';
|
|
8
|
+
|
|
9
|
+
// Parse a `;`-separated list of regex pattern strings. Empty entries are dropped.
|
|
10
|
+
// We do NOT compile here — that happens lazily in policy.js so config-loader stays
|
|
11
|
+
// free of regex error handling.
|
|
12
|
+
function parsePatternList(raw) {
|
|
13
|
+
if (!raw || typeof raw !== 'string') return [];
|
|
14
|
+
return raw
|
|
15
|
+
.split(';')
|
|
16
|
+
.map((s) => s.trim())
|
|
17
|
+
.filter((s) => s.length > 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Normalize a mode string. Returns 'unrestricted' for any falsy/unknown input,
|
|
21
|
+
// after logging a warning when the input is set but invalid. This keeps existing
|
|
22
|
+
// configs (no MODE field) on the fast path.
|
|
23
|
+
function normalizeMode(raw, serverName) {
|
|
24
|
+
if (raw === undefined || raw === null || raw === '') return 'unrestricted';
|
|
25
|
+
const normalized = String(raw).toLowerCase().trim();
|
|
26
|
+
if (!VALID_MODES.has(normalized)) {
|
|
27
|
+
logger.warn(
|
|
28
|
+
`Unknown security mode "${raw}" for server "${serverName}" — falling back to "unrestricted". Valid: ${[...VALID_MODES].join(', ')}.`
|
|
29
|
+
);
|
|
30
|
+
return 'unrestricted';
|
|
31
|
+
}
|
|
32
|
+
return normalized;
|
|
33
|
+
}
|
|
7
34
|
|
|
8
35
|
export class ConfigLoader {
|
|
9
36
|
constructor() {
|
|
@@ -81,6 +108,22 @@ export class ConfigLoader {
|
|
|
81
108
|
if (config.ssh_servers) {
|
|
82
109
|
for (const [name, serverConfig] of Object.entries(config.ssh_servers)) {
|
|
83
110
|
const normalizedName = name.toLowerCase();
|
|
111
|
+
// allow_patterns / deny_patterns may be either a TOML array of strings
|
|
112
|
+
// or a single `;`-separated string. Normalize to a string[] of regex
|
|
113
|
+
// sources — compilation happens in policy.js.
|
|
114
|
+
const tomlAllow = Array.isArray(serverConfig.allow_patterns)
|
|
115
|
+
? serverConfig.allow_patterns
|
|
116
|
+
: parsePatternList(serverConfig.allow_patterns);
|
|
117
|
+
const tomlDeny = Array.isArray(serverConfig.deny_patterns)
|
|
118
|
+
? serverConfig.deny_patterns
|
|
119
|
+
: parsePatternList(serverConfig.deny_patterns);
|
|
120
|
+
const mode = normalizeMode(serverConfig.mode, normalizedName);
|
|
121
|
+
if (mode === 'restricted' && tomlAllow.length === 0) {
|
|
122
|
+
logger.warn(
|
|
123
|
+
`Server "${normalizedName}" is in "restricted" mode but has no allow_patterns — every command will be refused. Set allow_patterns to enable any execution.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
84
127
|
this.servers.set(normalizedName, {
|
|
85
128
|
name: normalizedName,
|
|
86
129
|
host: serverConfig.host,
|
|
@@ -95,6 +138,10 @@ export class ConfigLoader {
|
|
|
95
138
|
platform: serverConfig.platform ? serverConfig.platform.toLowerCase() : undefined,
|
|
96
139
|
proxyJump: serverConfig.proxy_jump,
|
|
97
140
|
proxyCommand: serverConfig.proxy_command || serverConfig.proxycommand,
|
|
141
|
+
mode,
|
|
142
|
+
allowPatterns: tomlAllow,
|
|
143
|
+
denyPatterns: tomlDeny,
|
|
144
|
+
auditLog: serverConfig.audit_log,
|
|
98
145
|
source: 'toml'
|
|
99
146
|
});
|
|
100
147
|
}
|
|
@@ -131,6 +178,15 @@ export class ConfigLoader {
|
|
|
131
178
|
// Skip if already processed from a higher priority source
|
|
132
179
|
if (processedServers.has(serverName)) continue;
|
|
133
180
|
|
|
181
|
+
const envAllow = parsePatternList(env[`SSH_SERVER_${match[1]}_ALLOW_PATTERNS`]);
|
|
182
|
+
const envDeny = parsePatternList(env[`SSH_SERVER_${match[1]}_DENY_PATTERNS`]);
|
|
183
|
+
const mode = normalizeMode(env[`SSH_SERVER_${match[1]}_MODE`], serverName);
|
|
184
|
+
if (mode === 'restricted' && envAllow.length === 0) {
|
|
185
|
+
logger.warn(
|
|
186
|
+
`Server "${serverName}" is in "restricted" mode but has no SSH_SERVER_${match[1]}_ALLOW_PATTERNS — every command will be refused. Set ALLOW_PATTERNS to enable any execution.`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
134
190
|
const server = {
|
|
135
191
|
name: serverName,
|
|
136
192
|
host: value,
|
|
@@ -145,6 +201,10 @@ export class ConfigLoader {
|
|
|
145
201
|
platform: (env[`SSH_SERVER_${match[1]}_PLATFORM`] || '').toLowerCase() || undefined,
|
|
146
202
|
proxyJump: env[`SSH_SERVER_${match[1]}_PROXYJUMP`],
|
|
147
203
|
proxyCommand: env[`SSH_SERVER_${match[1]}_PROXYCOMMAND`],
|
|
204
|
+
mode,
|
|
205
|
+
allowPatterns: envAllow,
|
|
206
|
+
denyPatterns: envDeny,
|
|
207
|
+
auditLog: env[`SSH_SERVER_${match[1]}_AUDIT_LOG`],
|
|
148
208
|
source: 'env'
|
|
149
209
|
};
|
|
150
210
|
|
|
@@ -199,6 +259,16 @@ export class ConfigLoader {
|
|
|
199
259
|
if (server.platform) serverConfig.platform = server.platform;
|
|
200
260
|
if (server.proxyJump) serverConfig.proxy_jump = server.proxyJump;
|
|
201
261
|
if (server.proxyCommand) serverConfig.proxy_command = server.proxyCommand;
|
|
262
|
+
// Only emit security fields if they diverge from defaults — keeps generated
|
|
263
|
+
// TOML files clean for users who never opted in.
|
|
264
|
+
if (server.mode && server.mode !== 'unrestricted') serverConfig.mode = server.mode;
|
|
265
|
+
if (server.allowPatterns && server.allowPatterns.length > 0) {
|
|
266
|
+
serverConfig.allow_patterns = server.allowPatterns;
|
|
267
|
+
}
|
|
268
|
+
if (server.denyPatterns && server.denyPatterns.length > 0) {
|
|
269
|
+
serverConfig.deny_patterns = server.denyPatterns;
|
|
270
|
+
}
|
|
271
|
+
if (server.auditLog) serverConfig.audit_log = server.auditLog;
|
|
202
272
|
|
|
203
273
|
config.ssh_servers[name] = serverConfig;
|
|
204
274
|
}
|
|
@@ -229,6 +299,18 @@ export class ConfigLoader {
|
|
|
229
299
|
if (server.platform) lines.push(`SSH_SERVER_${upperName}_PLATFORM=${server.platform}`);
|
|
230
300
|
if (server.proxyJump) lines.push(`SSH_SERVER_${upperName}_PROXYJUMP=${server.proxyJump}`);
|
|
231
301
|
if (server.proxyCommand) lines.push(`SSH_SERVER_${upperName}_PROXYCOMMAND=${server.proxyCommand}`);
|
|
302
|
+
// Security fields — only emit when non-default to avoid clutter in
|
|
303
|
+
// generated .env files for users who never opted in.
|
|
304
|
+
if (server.mode && server.mode !== 'unrestricted') {
|
|
305
|
+
lines.push(`SSH_SERVER_${upperName}_MODE=${server.mode}`);
|
|
306
|
+
}
|
|
307
|
+
if (server.allowPatterns && server.allowPatterns.length > 0) {
|
|
308
|
+
lines.push(`SSH_SERVER_${upperName}_ALLOW_PATTERNS="${server.allowPatterns.join(';')}"`);
|
|
309
|
+
}
|
|
310
|
+
if (server.denyPatterns && server.denyPatterns.length > 0) {
|
|
311
|
+
lines.push(`SSH_SERVER_${upperName}_DENY_PATTERNS="${server.denyPatterns.join(';')}"`);
|
|
312
|
+
}
|
|
313
|
+
if (server.auditLog) lines.push(`SSH_SERVER_${upperName}_AUDIT_LOG=${server.auditLog}`);
|
|
232
314
|
lines.push('');
|
|
233
315
|
}
|
|
234
316
|
|