🔒 Improve SSH connection handling, enhance file transfer reliability, and update OAuth error handling and tests

This commit is contained in:
2026-01-30 04:53:18 +00:00
parent ab595394be
commit 9fdfbb22d8
14 changed files with 218 additions and 103 deletions

57
test-ssh.js Normal file
View File

@@ -0,0 +1,57 @@
#!/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);
}