fix: try to avoid asking ssh passphrase every time while communicating with remote (#1577)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-08-13 16:53:54 +08:00
parent ffa1a36e69
commit e87eb8137b

View File

@@ -176,8 +176,10 @@ namespace SourceGit.Commands
// Force using this app as SSH askpass program
var selfExecFile = Process.GetCurrentProcess().MainModule!.FileName;
start.Environment.Add("SSH_ASKPASS", selfExecFile); // Can not use parameter here, because it invoked by SSH with `exec`
start.Environment.Add("SSH_ASKPASS_REQUIRE", "force");
start.Environment.Add("SSH_ASKPASS_REQUIRE", "prefer");
start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE");
if (!OperatingSystem.IsLinux())
start.Environment.Add("DISPLAY", "required");
// If an SSH private key was provided, sets the environment.
if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey))