feat: ssh.ts

This commit is contained in:
2026-01-11 14:05:25 +08:00
parent c9c1911085
commit 1df4686bbd

View File

@@ -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(" ")}`);