feat(pi-ssh): support SSH agent authentication

This commit is contained in:
云服务部-叶林立
2026-08-26 20:01:45 +08:00
parent b7758b239e
commit 874d4da096
10 changed files with 98 additions and 22 deletions
+12
View File
@@ -37,6 +37,18 @@ export function effectiveValues(config: EffectiveSshConfig, key: string): string
return config.get(key.toLowerCase()) ?? [];
}
export function effectiveIdentityAgent(
config: EffectiveSshConfig,
env: NodeJS.ProcessEnv = process.env,
): string | undefined {
const configured = effectiveValue(config, "identityagent")?.replace(/^"|"$/g, "");
if (!configured || configured.toLowerCase() === "none") return undefined;
if (configured === "SSH_AUTH_SOCK" || configured === "$SSH_AUTH_SOCK" || configured === "${SSH_AUTH_SOCK}") {
return env.SSH_AUTH_SOCK;
}
return configured;
}
export function listDirectSshAliases(configPath = join(homedir(), ".ssh", "config")): string[] {
if (!existsSync(configPath)) return [];
const aliases: string[] = [];