Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use SSH remotes with GitHub Desktop?

Tags:

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?

like image 678
MAX POWER Avatar asked Jul 11 '19 15:07

MAX POWER


2 Answers

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.

like image 157
VonC Avatar answered Oct 21 '22 04:10

VonC


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"
like image 31
Tony Avatar answered Oct 21 '22 05:10

Tony