#!/usr/bin/env node import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; import { execSync } from 'child_process'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); function expandTilde(filepath) { if (filepath.startsWith('~/')) { return path.join(process.env.HOME, filepath.slice(2)); } return filepath; } const keyPath = expandTilde('~/.ssh/ds3627xs_gregrjacobs'); const sshConfig = { host: '10.0.0.81', port: 2323, username: 'GregRJacobs' }; console.log('๐Ÿ”ง Testing SSH Connection\n'); console.log( `๐Ÿ“ Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}` ); console.log(`๐Ÿ”‘ Key: ${keyPath}`); // Check key exists if (!fs.existsSync(keyPath)) { console.error(`โŒ SSH key not found: ${keyPath}`); process.exit(1); } const keyStats = fs.statSync(keyPath); console.log(`๐Ÿ“‚ Key file size: ${keyStats.size} bytes`); console.log(`๐Ÿ“… Modified: ${keyStats.mtime}\n`); // Test SSH connection console.log('๐Ÿงช Testing SSH connection with verbose output:\n'); const sshCmd = `ssh -v -p ${sshConfig.port} -i "${keyPath}" -o StrictHostKeyChecking=no ${sshConfig.username}@${sshConfig.host} "echo 'SSH connection successful!' && pwd"`; try { const output = execSync(sshCmd, { encoding: 'utf8', timeout: 10000 }); console.log('โœ… SUCCESS!\n'); console.log(output); } catch (error) { console.error('โŒ FAILED\n'); console.error('Error:', error.message); console.error('\nDebug Info:'); if (error.stderr) { console.error('Stderr:', error.stderr); } process.exit(1); }