29

I am using GitHub Desktop on Windows 10. I initially cloned a repo using its HTTPS URL, but now our organisation have advised that we must use the SSH URL instead. So I have changed this over.

I have also copied the contents of my public SSH key (id_rsa.pub) in to my GitHub account. My SSH key is protected by a passphrase.

Now when I try to do to a sync in GitHub Desktop I get the following error:

enter image description here

In Git Bash it works fine (it asks me for my passphrase before each pull/push though). Any idea what I need to do to make this work?

isherwood
  • 58,414
  • 16
  • 114
  • 157
MAX POWER
  • 5,213
  • 15
  • 89
  • 141

6 Answers6

11

As more recently seen in "Permission failure cloning in Git in Windows", try and launch GitHub Desktop after:
(warning: read comments first)

git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

That will ensure GitHub Desktop to use the right OpenSSH ssh.exe, instead of an internal one, as seen in desktop/desktop issue 5641.

If Git bash does not work properly after that, you can either:

  • revert the configuration:

    git config --global --unset core.sshCommand 
    
  • or use the Git for Windows SSH

    git config --global core.sshCommand "'C:\Program Files\Git\usr\bin\ssh.exe'"
    

If C:\Program Files\Git\usr\bin\ is already in your %PATH%, you don't even need that configuration: the ssh.exe from Git For Windows would be the one selected by default.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Does not work for me. Before this, at least git bash was working. – DarkMath Oct 29 '20 at 12:20
  • @DarkMath OK, what version of Windows and of Git are you using? And you can cancel that with `git config --global unset core.sshCommand` – VonC Oct 29 '20 at 12:42
  • **Don't do this, it will make your Git bash stop working, at least that's what happened to me.** I should have read @DarkMath comment... smh – Raphael Setin Mar 22 '22 at 20:58
  • @RaphaelSetin But you should be able to revert it easily enough: `git config --global --unset core.sshCommand` – VonC Mar 22 '22 at 21:19
  • 2
    @RaphaelSetin I have edited the answer to include a clearer warning on the unintended consequences of that `git config` option. – VonC Mar 22 '22 at 21:24
  • 2
    I figured a way to revert it, but thank you for adding it there; it will help others for sure if this happens to them too – Raphael Setin Mar 24 '22 at 00:05
3

solved the problem by unticking the system OpenSSH setting.

enter image description here

MGY
  • 7,245
  • 5
  • 41
  • 74
205 lng
  • 41
  • 2
2

I was able to get it working by creating an ssh config file with the content similar to what is provided in this gist:

https://gist.github.com/JoaquimLey/e6049a12c8fd2923611802384cd2fb4a

The minimal content I needed to get it working was

Host github.com
    IdentityFile /c/Users/username/.ssh/id_github

When cloning the repository I had to use the URL option because the Github.com tab will use the HTTPS url.

UnsafeUser
  • 33
  • 6
2

After searching and trying to use ssh-agent unsuccessfully, I found if you start github desktop using a git bash shell, it will prompt you for a passphrase. I added an alias to my .bash_profile to make starting github desktop easy.

eval C:/Users/labrat/AppData/Local/GitHubDesktop/GitHubDesktop.exe

I also have my git core.sshCommand set to this, which works for both git bash and github desktop:

git config core.sshCommand "'C:\\Program Files\\Git\\usr\\bin\\ssh.exe' -i C:/Home/.ssh/id_rsa_name"
Tony
  • 21
  • 1
0

I had this issue now as well. SSH was working fine in git-bash with ssh-agent and so forth.

But if you use TortoiseGit, for me the easiest was to use TortoiseGitPlink.exe globally as ssh-client, from TortoiseGit, git-bash and github desktop:

git config --global core.sshCommand "'C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe'"

This will by default use Pageant to cache your passphrase for current session. After setting this, GitHub Desktop immediately started working again with ssh repos.

beginner_
  • 7,230
  • 18
  • 70
  • 127
0

I had this issue but was related to my Docker container ssh keys weren't in my windows .ssh/ folder.

%userprofile%.ssh/

pleshy
  • 1,468
  • 2
  • 16
  • 22