From bfc26f4791c9a5fa66dfa2f2175d90d4d7bef8b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 18 Nov 2025 16:52:50 +0000 Subject: [PATCH] Add SSH config generation for global SSH keys Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- back/services/sshKey.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/back/services/sshKey.ts b/back/services/sshKey.ts index 5320c584..f3b6308e 100644 --- a/back/services/sshKey.ts +++ b/back/services/sshKey.ts @@ -134,9 +134,29 @@ export default class SshKeyService { public async addGlobalSSHKey(key: string, alias: string): Promise { await this.generatePrivateKeyFile(`global_${alias}`, key); + // Create a global SSH config entry that matches all hosts + // This allows the key to be used for any Git repository + await this.generateGlobalSshConfig(`global_${alias}`); } public async removeGlobalSSHKey(alias: string): Promise { await this.removePrivateKeyFile(`global_${alias}`); + await this.removeSshConfig(`global_${alias}`); + } + + private async generateGlobalSshConfig(alias: string) { + // Create a config that matches all hosts, making this key globally available + const config = `Host *\n IdentityFile ${path.join( + this.sshPath, + alias, + )}\n StrictHostKeyChecking no\n`; + await writeFileWithLock( + `${path.join(this.sshPath, `${alias}.config`)}`, + config, + { + encoding: 'utf8', + mode: '600', + }, + ); } }