mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat(pi-ssh): support SSH agent authentication
This commit is contained in:
@@ -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[] = [];
|
||||
|
||||
Reference in New Issue
Block a user