How to Bridge SSH Agent Access Between Windows and WSL Without Copying Keys
A supported-boundary SSH workflow that delegates to Windows OpenSSH from WSL, uses the Windows agent, preserves host identity, and avoids private-key copies.
Windows OpenSSH Authentication Agent exposes a Windows named pipe, while Linux OpenSSH clients expect a Unix-domain socket in SSH_AUTH_SOCK. There is no native path string that makes one protocol become the other. The least fragile supported-boundary solution is often to invoke the Windows ssh.exe from WSL, so the entire Windows client talks to its own Windows agent. Private keys stay in the agent’s Windows-managed context.
Prepare and verify Windows OpenSSH
In an authorized elevated PowerShell session, verify the OpenSSH Client capability and agent service according to Microsoft documentation. Organizational policy may keep ssh-agent manual/disabled; do not change it without approval. Start the service and add a key from a normal PowerShell session:
Get-Service ssh-agent
ssh-add.exe -l
ssh-add.exe $env:USERPROFILE\.ssh\id_ed25519
Use a passphrase, hardware-backed/FIDO key where supported, and file ACLs that Windows OpenSSH accepts. ssh-add -l lists public fingerprints; compare them to an inventory. Never copy a private key into both %USERPROFILE%\.ssh and WSL merely to silence a prompt.
From WSL, invoke the Windows client explicitly:
/mnt/c/Windows/System32/OpenSSH/ssh.exe -V
/mnt/c/Windows/System32/OpenSSH/ssh-add.exe -l
/mnt/c/Windows/System32/OpenSSH/ssh.exe [email protected]
WSL interoperability starts the Windows executable under the Windows user. The client reads Windows OpenSSH configuration and known hosts—normally under %USERPROFILE%\.ssh—not Linux ~/.ssh. Maintain host-key verification there and investigate changed-key warnings; do not add StrictHostKeyChecking=no.
Delegate Git SSH deliberately
Linux Git can use the Windows client for SSH remotes:
git config --global core.sshCommand \
'/mnt/c/Windows/System32/OpenSSH/ssh.exe'
git config --show-origin --get core.sshCommand
git ls-remote [email protected]:team/repository.git
Test against an authorized repository. This global setting affects every SSH remote and changes which SSH config/known-hosts file applies; prefer repository or conditional Git config if only some workflows should use Windows credentials. Remove the setting with git config --global --unset core.sshCommand to roll back.
Arguments that contain local file paths need attention because a Windows executable does not understand arbitrary Linux paths. Convert a deliberate file with wslpath -w and pass it as a quoted argument. Git’s ordinary remote invocation usually needs no local identity path when the agent holds the key.
Understand what this does not bridge
This method delegates SSH; it does not create SSH_AUTH_SOCK for Linux-native programs. Tools that require the agent protocol directly cannot use the Windows pipe through a symlink. Third-party relay designs translate a named pipe to a Unix socket, but they add privileged IPC, binary provenance, socket permissions, startup, and lifetime risks and lack one universal Microsoft-supported configuration.
If a Linux-native client is mandatory, use a separate Linux agent with a hardware token or a dedicated key, or an organization-approved maintained bridge reviewed against the threat model. Agent forwarding (ssh -A) is different: it forwards an agent to a remote host, which can request signatures while connected; enable it only per trusted host.
Test security and lifecycle
Verify expected key fingerprint, host-key database, passphrase prompting, agent restart, Windows logout, WSL restart, key removal, multiple Windows accounts, Git submodules, VS Code/IDE behavior, and revoked server access. Confirm ssh-add.exe -D or service stop removes usable identities as policy expects.
The clean bridge keeps one private-key copy and uses native Windows OpenSSH end to end. Its limitation is explicit: Linux delegates the client rather than pretending a Windows pipe is a Linux agent socket.
Related:
- Fixing a WSL Service That Windows Cannot Reach on localhost
- Sparse VHD Support in WSL: Automatic Reclamation, Limits, and Safe Verification
Sources: