This error occurs when Git for Windows cannot communicate with Pageant, the PuTTY SSH authentication agent. The fix involves starting Pageant, loading your SSH keys, or switching to OpenSSH for authentication.
This error indicates that Git is configured to use PuTTY's Pageant as the SSH authentication agent, but Pageant is either not running or not accessible. Pageant is part of the PuTTY suite and manages SSH private keys for Windows applications. When you attempt to clone, push, pull, or fetch from a remote repository using SSH, Git needs to authenticate with the server. If Git is configured to use PuTTY tools (plink.exe) instead of OpenSSH, it looks for Pageant to provide the SSH keys. When Pageant isn't running or hasn't loaded your keys, Git cannot authenticate and displays this error. The "fatal: Could not read from remote repository" message confirms that Git was completely unable to access the repository because SSH authentication failed before any connection could be established.
First, verify whether Pageant is currently running:
1. Look in the system tray (bottom-right corner of Windows taskbar)
- Click the "^" arrow to show hidden icons
- Look for the Pageant icon (a computer with a hat)
2. Check via Task Manager:
Press Ctrl+Shift+Esc to open Task Manager
Look for "pageant.exe" in the list of processes3. Check from command line:
# PowerShell
Get-Process pageant -ErrorAction SilentlyContinue
# Or Command Prompt
tasklist | findstr pageantIf Pageant is not running, proceed to start it. If it is running but you still see the error, your keys may not be loaded.
Start Pageant and add your SSH private key:
Start Pageant:
1. Open the Start menu and search for "Pageant"
2. Or navigate to your PuTTY installation folder and double-click pageant.exe
3. Pageant will appear in your system tray
Load your SSH key:
1. Right-click the Pageant icon in the system tray
2. Select "Add Key"
3. Navigate to your private key file (.ppk format)
4. Enter your passphrase if prompted
5. Click "Open"
Verify the key is loaded:
1. Right-click the Pageant icon
2. Select "View Keys"
3. Your key should appear in the list
Alternative - Load key from command line:
"C:\Program Files\PuTTY\pageant.exe" "C:\Users\YourName\.ssh\your_key.ppk"Note: Pageant requires keys in PuTTY's .ppk format. If you have an OpenSSH key (like id_rsa or id_ed25519), you'll need to convert it first (see advanced notes).
To avoid this error after every restart, configure Pageant to start automatically with your keys:
Option 1: Add Pageant to Windows Startup
1. Press Win+R and type shell:startup
2. Create a shortcut to Pageant with your key as an argument
3. Right-click in the Startup folder > New > Shortcut
4. Enter the path:
"C:\Program Files\PuTTY\pageant.exe" "C:\Users\YourName\.ssh\your_key.ppk"5. Name the shortcut "Pageant" and click Finish
Option 2: Create a batch file:
@echo off
start "" "C:\Program Files\PuTTY\pageant.exe" "C:\Users\YourName\.ssh\your_key.ppk"Save as start-pageant.bat in your Startup folder.
Option 3: Use Task Scheduler
1. Open Task Scheduler
2. Create a new task to run at logon
3. Set the action to start Pageant with your key path
Note: If your key has a passphrase, you'll still be prompted to enter it when Pageant starts.
If you prefer to use Windows built-in OpenSSH instead of PuTTY tools, reconfigure Git:
Check current Git SSH configuration:
# Check GIT_SSH environment variable
echo %GIT_SSH%
# Or in PowerShell
$env:GIT_SSHIf this points to plink.exe, Git is using PuTTY.
Remove the GIT_SSH setting:
# Remove from current session
set GIT_SSH=
# Remove permanently (System Properties > Environment Variables)
# Or via PowerShell (run as Administrator)
[Environment]::SetEnvironmentVariable("GIT_SSH", $null, "User")Configure Git to use OpenSSH:
# Set Git to use Windows OpenSSH
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
# Or for Git Bash's built-in SSH
git config --global core.sshCommand "ssh"Verify the change:
git config --global core.sshCommandAfter this change, Git will use OpenSSH instead of PuTTY, and you won't need Pageant.
If you switched to OpenSSH, set up SSH authentication:
Start the OpenSSH Authentication Agent:
# Check if service is running (run PowerShell as Administrator)
Get-Service ssh-agent
# Set to start automatically
Set-Service -Name ssh-agent -StartupType Automatic
# Start the service
Start-Service ssh-agentGenerate or use existing SSH keys:
# Generate a new key (if needed)
ssh-keygen -t ed25519 -C "[email protected]"
# Add your key to the agent
ssh-add ~/.ssh/id_ed25519Test the connection:
ssh -T [email protected]You should see: "Hi username! You've successfully authenticated..."
If you have an existing PuTTY key (.ppk):
You'll need to convert it to OpenSSH format using PuTTYgen:
1. Open PuTTYgen
2. Click "Load" and select your .ppk file
3. Go to Conversions > Export OpenSSH key
4. Save as ~/.ssh/id_rsa or similar
5. Add to ssh-agent with ssh-add
Confirm Git is using the correct SSH method:
Check all SSH-related settings:
# Check core.sshCommand
git config --global core.sshCommand
# Check GIT_SSH environment variable
echo %GIT_SSH%
# List all SSH-related config
git config --list | findstr -i sshTest Git SSH access:
# Use GIT_TRACE for detailed debugging
set GIT_TRACE=1
git ls-remote [email protected]:username/repo.git
# Or with SSH debugging
set GIT_SSH_COMMAND=ssh -vvv
git ls-remote [email protected]:username/repo.gitExpected behavior:
- If using Pageant: Git should use plink.exe and require Pageant running
- If using OpenSSH: Git should use Windows ssh.exe and use ssh-agent
Verify which SSH is being used:
# In Git Bash
which ssh
# Should show:
# /usr/bin/ssh (Git Bash's OpenSSH)
# or
# /c/Windows/System32/OpenSSH/ssh (Windows OpenSSH)If Pageant is running with keys loaded but Git still can't connect:
Verify plink can reach Pageant:
# Test with plink directly
plink -v [email protected]Look for messages about Pageant in the output.
Check if running as different user:
Pageant only serves keys to processes running as the same Windows user. If you:
- Run Git as Administrator but Pageant as regular user
- Use a service account for builds
- Run in a different Remote Desktop session
The processes cannot share Pageant's keys.
Solutions:
1. Run Git in the same user context as Pageant
2. For services, use the Windows Credential Manager or deploy keys
3. For CI/CD, use OpenSSH with key files instead of Pageant
Antivirus/Security software interference:
Some security software blocks inter-process communication:
1. Temporarily disable antivirus
2. Check if Pageant is whitelisted
3. Look for blocked connections in security logs
Restart Pageant:
# Kill and restart Pageant
taskkill /F /IM pageant.exe
"C:\Program Files\PuTTY\pageant.exe" "C:\path\to\your\key.ppk"### Converting OpenSSH Keys to PuTTY Format
If you have OpenSSH keys and need to use them with Pageant:
1. Open PuTTYgen
2. Click "Load"
3. Change file filter to "All Files (*.*)"
4. Select your private key (id_rsa, id_ed25519, etc.)
5. Enter passphrase if prompted
6. Click "Save private key"
7. Save as .ppk file### Converting PuTTY Keys to OpenSSH Format
1. Open PuTTYgen
2. Click "Load" and select your .ppk file
3. Go to Conversions > Export OpenSSH key
4. Save to ~/.ssh/ with appropriate name
5. Set permissions (in Git Bash):
chmod 600 ~/.ssh/id_rsa### Using Pageant with WSL
Pageant cannot directly serve keys to WSL (Windows Subsystem for Linux). Options:
Option 1: Use wsl-ssh-pageant
A bridge that allows WSL to use Pageant keys:
# In WSL, add to ~/.bashrc
export SSH_AUTH_SOCK=/mnt/c/Users/YourName/wsl-ssh-pageant/ssh-agent.sockOption 2: Use Windows OpenSSH from WSL
# Add to ~/.bashrc
export GIT_SSH="/mnt/c/Windows/System32/OpenSSH/ssh.exe"Option 3: Use native WSL SSH
Generate and manage keys entirely within WSL using standard Linux ssh-agent.
### Multiple PuTTY Key Management
For multiple keys or accounts:
# Load multiple keys at startup
pageant.exe key1.ppk key2.ppk key3.ppkOr use separate Pageant instances (not recommended) with different pipes.
### Git Configuration for Specific Repositories
You can configure SSH settings per-repository:
# For a specific repo, use OpenSSH
cd /path/to/repo
git config core.sshCommand "ssh"
# For another repo, use PuTTY
cd /path/to/other-repo
git config core.sshCommand "plink"### Debugging PuTTY/Plink Connections
# Maximum verbosity with plink
plink -v -v [email protected]
# Check Pageant is accessible
set PLINK_PROTOCOL=ssh
plink -agent -v [email protected]### Environment Variable Priority
Git checks for SSH configuration in this order:
1. GIT_SSH_COMMAND (highest priority)
2. core.sshCommand git config
3. GIT_SSH environment variable
4. Default SSH on PATH
### Corporate/Enterprise Considerations
In enterprise environments:
- IT may require PuTTY for compliance/logging
- Check with your IT department before switching to OpenSSH
- Some proxy configurations only work with PuTTY
- Pageant may be managed centrally via Group Policy
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git