Solution:
Root Cause: SSH Agent Forwarding Socket Disconnection VS Code Remote uses SSH Agent Forwarding (
ForwardAgent yes) to allow git commands run inside the remote integrated terminal to authenticate using local client SSH keys. If the local SSH agent (Pageant, OpenSSH Authentication Agent, or
ssh-agent) crashes, restarts, or clears its key ring, the forwarded UNIX domain socket on the remote machine (
/tmp/ssh-XXXXXX/agent.XXXX) becomes stale. Attempts to run git operations or extension calls through this broken socket stall the remote extension process.
Diagnostic Verification: Inside the VS Code integrated terminal on the remote host, check if the forwarded agent socket responds:
If it returns
Could not open a connection to your authentication agent. or hangs indefinitely, agent forwarding is broken.
Step-by-Step Fix: 1 Restart Local SSH Agent Service (Windows Client):
Run PowerShell as Administrator and execute: Copy
powershell
Get-Service ssh-agent | Restart-Service
ssh-add %USERPROFILE%\.ssh\id_rsa
2 Restart Local SSH Agent Service (macOS / Linux Client):
Re-add your identity key to your active local agent: Copy
bash
eval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/id_rsa
3 Disable Unnecessary Agent Forwarding in SSH Config:
If agent forwarding is not strictly needed on the host, disable it in ~/.ssh/config to prevent agent-lock timeouts: Copy
sshconfig
Host my-remote-server
ForwardAgent no
ServerAliveInterval 15
Prevention & Long-Term Monitoring: Configure persistent SSH agent key persistence across system reboots on local developer machines.