fix(core): Allow GIT_SSH_COMMAND in simple-git after 3.36.0 upgrade (#29894)

This commit is contained in:
Daria 2026-05-06 16:08:25 +03:00 committed by GitHub
parent de3a98f58f
commit f42be9030e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -366,9 +366,15 @@ describe('SourceControlGitService', () => {
mockSourceControlPreferencesService.getPreferences.mockReturnValue({
connectionType: 'ssh',
} as never);
(simpleGit as jest.Mock).mockClear();
await sourceControlGitService.setGitCommand();
expect(simpleGit).toHaveBeenCalledWith(
expect.objectContaining({
unsafe: { allowUnsafeSshCommand: true },
}),
);
expect(mockGitInstance.env).toHaveBeenCalledWith(
'GIT_SSH_COMMAND',
'ssh -o UserKnownHostsFile=".ssh/known_hosts" -o StrictHostKeyChecking=accept-new -i "private-key"',

View File

@ -171,7 +171,12 @@ export class SourceControlGitService {
// - Subsequent connections: verifies against saved key
const sshCommand = `ssh -o UserKnownHostsFile="${escapedKnownHostsPath}" -o StrictHostKeyChecking=accept-new -i "${escapedPrivateKeyPath}"`;
this.git = simpleGit(this.gitOptions)
// Allow GIT_SSH_COMMAND so we can point SSH at n8n's own private key and known_hosts.
// This is safe because the command is constructed internally above, not from user input.
this.git = simpleGit({
...this.gitOptions,
unsafe: { allowUnsafeSshCommand: true },
})
.env('GIT_SSH_COMMAND', sshCommand)
.env('GIT_TERMINAL_PROMPT', '0');
}