Skip to content

Commit 6858184

Browse files
committed
fix(start-ssh-agent): support OpenSSH 10.1+ socket location
Update socket search paths from "%TEMP%\ssh-*" to "%USERPROFILE%\.ssh\agent\s.*" to align with OpenSSH 10.1+ security improvement that moved agent sockets from /tmp to $HOME This preserves the security benefits of restricting filesystem access while maintaining compatibility with the new default location.
1 parent 85dd204 commit 6858184

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mingw-w64-git/start-ssh-agent.cmd

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@
4040
@REM Connect up the current ssh-agent
4141
@IF [!SSH_AGENT_PID!] == [] @(
4242
@ECHO Removing old ssh-agent sockets
43-
@FOR /d %%d IN (%TEMP%\ssh-??????*) DO @RMDIR /s /q %%d
43+
@FOR %%s IN (%USERPROFILE%\.ssh\agent\s.*) DO @DEL /q "%%s" 2>nul
4444
) ELSE @(
4545
@ECHO Found ssh-agent at !SSH_AGENT_PID!
46-
@FOR /d %%d IN (%TEMP%\ssh-??????*) DO @(
47-
@FOR %%f IN (%%d\agent.*) DO @(
48-
@SET SSH_AUTH_SOCK=%%f
49-
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:%TEMP%=/tmp!
50-
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:\=/!
51-
)
46+
@FOR %%s IN (%USERPROFILE%\.ssh\agent\s.*) DO @(
47+
@SET SSH_AUTH_SOCK=%%s
48+
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:%USERPROFILE%=~!
49+
@SET SSH_AUTH_SOCK=!SSH_AUTH_SOCK:\=/!
5250
)
5351
@IF NOT [!SSH_AUTH_SOCK!] == [] @(
5452
@ECHO Found ssh-agent socket at !SSH_AUTH_SOCK!

0 commit comments

Comments
 (0)