From 1df4686bbd90c538f4631c9426d4181551c5fb72 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 11 Jan 2026 14:05:25 +0800 Subject: [PATCH] feat: ssh.ts --- single-scripts/ssh.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/single-scripts/ssh.ts b/single-scripts/ssh.ts index ca6cc91..4ac7c3d 100755 --- a/single-scripts/ssh.ts +++ b/single-scripts/ssh.ts @@ -81,6 +81,15 @@ function printSshConfig(sshConfig: SshConfig) { }`, ); } + + if (sshConfig.default_proxy || sshConfig.default_forward_agent) { + const features = []; + if (sshConfig.default_proxy) features.push("proxy"); + if (sshConfig.default_forward_agent) features.push("forward_agent"); + console.log( + `\n[INFO ] Global default features: [${features.join(" ")}]`, + ); + } } function loadSshConfig(): SshConfig { @@ -174,20 +183,23 @@ async function main() { const sshCommand = "ssh"; const sshArgs = []; - const sshUsername = username || sshProfile.default_username || - sshConfig.default_username || "root"; + const sshForwardAgent = sshTsArgs.forwardAgent || sshProfile.forward_agent || sshConfig.default_forward_agent || true; - const sshProxy = sshTsArgs.proxy || sshProfile.proxy || - sshConfig.default_proxy || false; if (sshForwardAgent) { sshArgs.push("-o"); sshArgs.push("ForwardAgent=yes"); } + + const sshProxy = sshTsArgs.proxy || sshProfile.proxy || + sshConfig.default_proxy || false; if (sshProxy) { sshArgs.push("-o"); sshArgs.push('"ProxyCommand=nc -X 5 -x 127.0.0.1:1080 %h %p"'); } + + const sshUsername = username || sshProfile.default_username || + sshConfig.default_username || "root"; sshArgs.push(`${sshUsername}@${sshProfile.host}`); console.log(`${GREEN}[OK ]${RESET} ${sshCommand} ${sshArgs.join(" ")}`);