Fix SSH global private key matching before subscription-specific keys (#2845)

* Initial plan

* Fix SSH global private key loading order by using zzz_ prefix

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Use tilde (~) prefix for global SSH config to ensure it loads last

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
Copilot 2025-11-21 01:53:58 +08:00 committed by GitHub
parent ee2fbe5335
commit d473c3ae88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,15 +133,15 @@ export default class SshKeyService {
} }
public async addGlobalSSHKey(key: string, alias: string): Promise<void> { public async addGlobalSSHKey(key: string, alias: string): Promise<void> {
await this.generatePrivateKeyFile(`global_${alias}`, key); await this.generatePrivateKeyFile(`~global_${alias}`, key);
// Create a global SSH config entry that matches all hosts // Create a global SSH config entry that matches all hosts
// This allows the key to be used for any Git repository // This allows the key to be used for any Git repository
await this.generateGlobalSshConfig(`global_${alias}`); await this.generateGlobalSshConfig(`~global_${alias}`);
} }
public async removeGlobalSSHKey(alias: string): Promise<void> { public async removeGlobalSSHKey(alias: string): Promise<void> {
await this.removePrivateKeyFile(`global_${alias}`); await this.removePrivateKeyFile(`~global_${alias}`);
await this.removeSshConfig(`global_${alias}`); await this.removeSshConfig(`~global_${alias}`);
} }
private async generateGlobalSshConfig(alias: string) { private async generateGlobalSshConfig(alias: string) {