Fixing GitHub Desktop SSH Authentication for Custom Hosts (Windows)

Prev Next

Fixing GitHub Desktop SSH Authentication for Custom Hosts (Windows)


🧩 Problem Summary

GitHub Desktop fails to push or clone repositories hosted on a custom SSH Git server (e.g., yourcompany.allspice.io), even though pushing from the command line works.


⚠️ Symptoms

  • GitHub Desktop error:

    • Authentication failed
  • Cannot push or clone via GitHub Desktop

  • Command line (git push) works successfully

  • Running ssh-add may fail with:

    • Could not open a connection to your authentication agent
    • or key not found errors

Here is an example failure

Failed to push

Authentication failed. Some common reasons include:

You are not logged in to your account: see File > Options.
You may need to log out and log back in to refresh your token.
You do not have permission to access this repository.
The repository is archived on GitHub. Check the repository settings to confirm you are still permitted to push commits.
If you use SSH authentication, check that your key is added to the ssh-agent and associated with your account.
If you use SSH authentication, ensure the host key verification passes for your repository hosting service.
If you used username / password authentication, you might need to use a Personal Access Token instead of your account password. Check the documentation of your repository hosting service.

Image


🧠 Root Cause

GitHub Desktop uses the Windows OpenSSH agent, which is separate from environments like Git Bash.

Additionally, SSH configuration may fail if:

  • The SSH agent is not running
  • The SSH key is not loaded into the agent
  • The IdentityFile path in ~/.ssh/config is not in Windows (DOS) format

✅ Solution

1. Start SSH Agent (Admin Required)

Open PowerShell as Administrator and run:

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent

2. Add SSH Key to Agent

Use the full Windows path (not ~):

ssh-add "C:\Users\<USERNAME>\.ssh\<your_key_name>"

Verify:

ssh-add -l

3. Configure SSH for Custom Host

Make sure you are editing a file config not config.txt

Edit:

C:\Users\<USERNAME>\.ssh\config

Add:

Host yourcompany.allspice.io
  HostName yourcompany.allspice.io
  User git
  IdentityFile C:\Users\<USERNAME>\.ssh\<your_key_name>
  IdentitiesOnly yes

⚠️ Important: The IdentityFile must use a Windows-style path (e.g., C:\Users\...), not ~/.ssh/...


4. Test SSH Connection

ssh -T git@your.allspice.io

5. Restart GitHub Desktop

Fully close and reopen GitHub Desktop, then retry push/clone.


✅ Expected Result

  • ssh-add -l shows your key
  • ssh -T authenticates successfully
  • GitHub Desktop can push and clone without errors

💡 Notes

  • GitHub Desktop does not use Git Bash’s SSH environment
  • Always configure SSH using the system (Windows) agent
  • This issue commonly appears when using custom Git hosts instead of github.com