Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
"no-console": ["warn", { "allow": ["warn", "error"] }],
"no-trailing-spaces": ["error"],
"eol-last": ["error", "always"],
"comma-dangle": ["error", "only-multiline"],
"object-curly-spacing": ["error", "always"],
"array-bracket-spacing": ["error", "never"]
}
},
"overrides": [
{
"files": ["tests/**/*.js", "examples/**/*.js", "debug/**/*.js", "scripts/**/*.{js,mjs,cjs}"],
"rules": { "no-console": "off" }
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20, 22]
node: [20, 22, 24]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- gitnexus:start -->
# GitNexus — Code Intelligence

This project is indexed by GitNexus as **claude-code-ssh** (1326 symbols, 3627 relationships, 110 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
This project is indexed by GitNexus as **claude-code-ssh** (1340 symbols, 3668 relationships, 111 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.

> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.

Expand Down
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The server exposes these tools to Claude Code and OpenAI Codex:
- `ssh_health_check`: Comprehensive server health check (CPU, RAM, Disk, Network)
- `ssh_service_status`: Check status of services (nginx, mysql, docker, etc.)
- `ssh_process_manager`: List, monitor, or kill processes
- `ssh_alert_setup`: Configure health monitoring alerts and thresholds
- `ssh_alert_setup`: Configure CPU/memory/disk thresholds per server; `check` action compares live metrics to thresholds

### Database Management (v2.3+)
- `ssh_db_dump`: Create database dumps (MySQL, PostgreSQL, MongoDB)
Expand Down Expand Up @@ -207,7 +207,7 @@ Configuration is stored in `~/.config/claude-code/claude_code_config.json`
<!-- gitnexus:start -->
# GitNexus — Code Intelligence

This project is indexed by GitNexus as **claude-code-ssh** (1326 symbols, 3627 relationships, 110 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
This project is indexed by GitNexus as **claude-code-ssh** (1340 symbols, 3668 relationships, 111 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.

> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.

Expand Down
3 changes: 1 addition & 2 deletions debug/test-efaje-connection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

import { Client } from 'ssh2';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';
Expand Down Expand Up @@ -83,4 +82,4 @@ conn.connect({
debug: (info) => {
console.log('[SSH2 DEBUG]', info);
}
});
});
5 changes: 2 additions & 3 deletions debug/test-host-verification.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import SSHManager from '../src/ssh-manager.js';
import { isHostKnown, getCurrentHostKey, removeHostKey } from '../src/ssh-key-manager.js';
import { isHostKnown, getCurrentHostKey } from '../src/ssh-key-manager.js';
import dotenv from 'dotenv';
import path from 'path';
import { fileURLToPath } from 'url';
Expand All @@ -12,7 +12,6 @@ const __dirname = path.dirname(__filename);
dotenv.config({ path: path.join(__dirname, '..', '.env') });

// Test configuration
const testServer = 'efaje_staging';
const config = {
host: process.env.SSH_SERVER_EFAJE_STAGING_HOST || '35.198.113.119',
port: parseInt(process.env.SSH_SERVER_EFAJE_STAGING_PORT) || 14072,
Expand Down Expand Up @@ -65,4 +64,4 @@ try {
}

console.log('');
console.log('✅ All tests passed!');
console.log('✅ All tests passed!');
10 changes: 5 additions & 5 deletions debug/test-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
/**
* Test script for the logger system
* Run with different environment variables to test different modes:
*
*
* SSH_VERBOSE=true node debug/test-logger.js
* SSH_LOG_LEVEL=DEBUG node debug/test-logger.js
* SSH_LOG_LEVEL=ERROR node debug/test-logger.js
*/

import { logger, LOG_LEVELS } from '../src/logger.js';
import { logger } from '../src/logger.js';

console.log('🧪 Testing Logger System');
console.log('========================');
Expand Down Expand Up @@ -79,8 +79,8 @@ setTimeout(() => {
history.forEach(entry => {
console.log(` - [${entry.timestamp}] ${entry.server}: ${entry.command?.substring(0, 50)} - ${entry.success ? '✅' : '❌'}`);
});

console.log('\n✅ Logger test complete!');
console.log(`Log file: ${process.env.SSH_LOG_FILE || '.ssh-manager.log'}`);
console.log(`History file: .ssh-command-history.json`);
}, 500);
console.log('History file: .ssh-command-history.json');
}, 500);
14 changes: 7 additions & 7 deletions debug/test-mcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ server.on('error', (error) => {
// Wait for server to start
setTimeout(() => {
console.log('\n📋 Sending initialization request...\n');

// Send initialization request
const initRequest = {
jsonrpc: '2.0',
Expand All @@ -52,27 +52,27 @@ setTimeout(() => {
},
id: 1
};

server.stdin.write(JSON.stringify(initRequest) + '\n');

// Wait and then request tools list
setTimeout(() => {
console.log('\n🔧 Requesting tools list...\n');

const toolsRequest = {
jsonrpc: '2.0',
method: 'tools/list',
params: {},
id: 2
};

server.stdin.write(JSON.stringify(toolsRequest) + '\n');

// Give time for response then exit
setTimeout(() => {
console.log('\n✅ Test complete. Shutting down...');
server.kill();
process.exit(0);
}, 2000);
}, 1000);
}, 500);
}, 500);
24 changes: 12 additions & 12 deletions debug/test-ssh-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ setTimeout(() => {
},
id: ++requestId
};

server.stdin.write(JSON.stringify(initRequest) + '\n');

// Test ssh_list_servers
setTimeout(() => {
console.log('\n📋 Testing ssh_list_servers...\n');

const listRequest = {
jsonrpc: '2.0',
method: 'tools/call',
Expand All @@ -69,13 +69,13 @@ setTimeout(() => {
},
id: ++requestId
};

server.stdin.write(JSON.stringify(listRequest) + '\n');

// Test ssh_execute
setTimeout(() => {
console.log('\n🚀 Testing ssh_execute (ls -la)...\n');

const execRequest = {
jsonrpc: '2.0',
method: 'tools/call',
Expand All @@ -88,13 +88,13 @@ setTimeout(() => {
},
id: ++requestId
};

server.stdin.write(JSON.stringify(execRequest) + '\n');

// Test ssh_execute with working directory
setTimeout(() => {
console.log('\n📁 Testing ssh_execute with working directory...\n');

const execCwdRequest = {
jsonrpc: '2.0',
method: 'tools/call',
Expand All @@ -108,9 +108,9 @@ setTimeout(() => {
},
id: ++requestId
};

server.stdin.write(JSON.stringify(execCwdRequest) + '\n');

// Exit after tests
setTimeout(() => {
console.log('\n✅ All tests complete. Shutting down...');
Expand All @@ -120,4 +120,4 @@ setTimeout(() => {
}, 2000);
}, 2000);
}, 1000);
}, 500);
}, 500);
2 changes: 1 addition & 1 deletion docs/TOOL_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ System health checks and monitoring:
- `ssh_process_manager` - List, monitor, or kill processes
- `ssh_monitor` - Real-time system resource monitoring
- `ssh_tail` - Tail log files in real-time
- `ssh_alert_setup` - Configure health monitoring alerts and thresholds
- `ssh_alert_setup` - Configure CPU/memory/disk thresholds; `check` compares live health_check to thresholds

**When to use**: Enable for server administration, DevOps work, or troubleshooting.

Expand Down
73 changes: 37 additions & 36 deletions examples/backup-workflow.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// @ts-nocheck
/**
* Backup Workflow Examples for claude-code-ssh
*
* This file demonstrates various backup and restore workflows
* that can be executed through Claude Code or OpenAI Codex.
* The declarations below are illustrative; they are not executed here.
*/
/* eslint-disable no-unused-vars, no-undef */

// ============================================================================
// EXAMPLE 1: Simple MySQL Backup Before Deployment
Expand Down Expand Up @@ -255,7 +258,7 @@ Complete deployment workflow with backup safety net

async function preDeploymentWorkflow() {
// Step 1: Create backup
console.log("Creating pre-deployment backup...");
console.log('Creating pre-deployment backup...');
const backup = await createBackup({
server: 'production',
type: 'mysql',
Expand All @@ -266,28 +269,28 @@ async function preDeploymentWorkflow() {
console.log(`Backup created: ${backup.backup_id}`);

// Step 2: Deploy changes
console.log("Deploying new version...");
console.log('Deploying new version...');
await deploy({
server: 'production',
branch: 'main'
});

// Step 3: Run health check
console.log("Running health checks...");
console.log('Running health checks...');
const health = await healthCheck({
server: 'production'
});

// Step 4: If deployment fails, restore backup
if (!health.success) {
console.error("Deployment failed! Rolling back...");
console.error('Deployment failed! Rolling back...');
await restoreBackup({
server: 'production',
backupId: backup.backup_id
});
console.log("Rollback completed");
console.log('Rollback completed');
} else {
console.log("Deployment successful!");
console.log('Deployment successful!');
}
}

Expand Down Expand Up @@ -316,7 +319,7 @@ async function disasterRecovery() {
});

if (!yesterdayBackup) {
throw new Error("No backup found from yesterday");
throw new Error('No backup found from yesterday');
}

// Step 3: Restore
Expand All @@ -326,7 +329,7 @@ async function disasterRecovery() {
backupId: yesterdayBackup.id
});

console.log("Recovery completed successfully");
console.log('Recovery completed successfully');
}

// ============================================================================
Expand Down Expand Up @@ -400,33 +403,31 @@ const monthlyCompliance = {
// CRON SCHEDULE REFERENCE
// ============================================================================

/*
Common cron schedules:

Daily:
- "0 2 * * *" // Every day at 2 AM
- "0 0 * * *" // Every day at midnight

Hourly:
- "0 * * * *" // Every hour at minute 0
- "0 */6 * * *" // Every 6 hours

Weekly:
- "0 0 * * 0" // Every Sunday at midnight
- "0 3 * * 1" // Every Monday at 3 AM

Monthly:
- "0 0 1 * *" // 1st of month at midnight
- "0 2 15 * *" // 15th of month at 2 AM

Weekdays:
- "0 1 * * 1-5" // Mon-Fri at 1 AM

Custom:
- "*/30 * * * *" // Every 30 minutes
- "0 */4 * * *" // Every 4 hours
- "0 9-17 * * *" // Every hour from 9 AM to 5 PM
*/
// Common cron schedules:
//
// Daily:
// "0 2 * * *" -> Every day at 2 AM
// "0 0 * * *" -> Every day at midnight
//
// Hourly:
// "0 * * * *" -> Every hour at minute 0
// "0 */6 * * *" -> Every 6 hours
//
// Weekly:
// "0 0 * * 0" -> Every Sunday at midnight
// "0 3 * * 1" -> Every Monday at 3 AM
//
// Monthly:
// "0 0 1 * *" -> 1st of month at midnight
// "0 2 15 * *" -> 15th of month at 2 AM
//
// Weekdays:
// "0 1 * * 1-5" -> Mon-Fri at 1 AM
//
// Custom:
// "*/30 * * * *" -> Every 30 minutes
// "0 */4 * * *" -> Every 4 hours
// "0 9-17 * * *" -> Every hour from 9 AM to 5 PM

// ============================================================================
// NOTES
Expand Down Expand Up @@ -466,7 +467,7 @@ Best Practices:
- Test disaster recovery procedures
*/

module.exports = {
export {
mysqlBackup,
postgresBackup,
filesBackup,
Expand Down
Loading
Loading