Skip to content

Reduce the pain of consuming SSH remotes #2579

Closed

Description

@shiftkey

There's a collection of issues spread across multiple issues which touch on situations involving SSH remotes:

I looked around, and I cannot see anywhere, either in the desktop app settings, nor in the settings for any repository, nor in my GitHub profile settings, where I would go about doing SSH remote configuration.

The classic apps addressed some of this (at least on the Windows side):

  • creating a new SSH key if not found and adding it to GitHub
  • ensuring ssh-agent was running when launching the app or Git Shell
  • setting the right environment variables when performing Git operations

Activity

  1. joshaber commented on Aug 31, 2017

    @joshaber
    Contributor

    The Classic Mac app did essentially the same as Windows, minus the ssh-agent stuff since that was unnecessary.

  2. mcmonkey4eva commented on Oct 11, 2017

    @mcmonkey4eva

    Does current GitHub Desktop support SSH remotes at all?
    I ran ssh-agent, did ssh-add on my keys (all on a random git bash instance) and it was all successful.
    Github Desktop then failed to fetch or pull an SSH repo.
    For reference, old Github-Windows client pulls the same fine.

    Fair note that I've never use ssh-agent manually before, so I may have messed up somewhere.

    So two things:

    • Full support for making this easy and automated in the new Desktop client.
    • How would I set it up under current limitations to where I can pull SSH repos in the new Desktop client?
  3. shiftkey commented on Oct 12, 2017

    @shiftkey
    MemberAuthor

    How would I set it up under current limitations to where I can pull SSH repos in the new Desktop client?

    @mcmonkey4eva I ran through this guide again using the latest version of Desktop, and I was able to push changes to an SSH remote using Desktop. Maybe ensure you do eval $(ssh-agent -s) before launching Desktop as this will environment variables that are important to Git.

  4. mcmonkey4eva commented on Oct 12, 2017

    @mcmonkey4eva

    I'm fairly sure SSH Agent is running fine.
    Evidence for this is that the command line will pull the repo happily.
    Desktop was started in first testing before the SSH Agent config, and later started after, as well as restarted past that point a few times. At no point was it able to pull.
    I'm using a standard Git Bash (right click desktop -> Git Bash Here) to open the SSH Agent.
    I've carefully ensured as well that there's never been more than one SSH Agent running at the same time. (Just launching the SSH Agent a second time will duplicate it normally)

  5. shiftkey commented on Oct 17, 2017

    @shiftkey
    MemberAuthor

    @mcmonkey4eva a thought: is there something interesting with your SSH key - does it have a passphrase associated with it?

  6. mcmonkey4eva commented on Oct 17, 2017

    @mcmonkey4eva

    Nope! Standard old-github-desktop autogenerated SSH key, whose pub file was uploaded to an unrelated git server.

  7. shiftkey commented on Oct 25, 2017

    @shiftkey
    MemberAuthor

    @mcmonkey4eva

    Standard old-github-desktop autogenerated SSH key

    Was it named github_rsa by any chance? That might be the issue - I've got a similar report of this which was fixed by renaming it to id_rsa.

  8. mcmonkey4eva commented on Oct 25, 2017

    @mcmonkey4eva

    It was yes .-.
    Thanks for the info!

  9. thenetimp commented on Nov 20, 2017

    @thenetimp

    Better error messages would be nice. For example on MacOS High Sierra if you don't use ssh-add to add your key because you are using a passphrase on your ssh key then github desktop throws a generic message of

    "Authentication failed. You may not have permission to access the repository or the repository may have been archived. Open preferences and verify that you're signed in with an account that has permission to access this repository."

    If this message had been more specific, it wouldn't have taken me 30 minutes to figure out what was going on....

  10. niik commented on Nov 30, 2017

    @niik
    Member

    Added link to #3457 in the body

  11. nanomebia commented on Dec 1, 2017

    @nanomebia

    it's probably a good idea to add in functionality to specify which key the desktop client will use by default (and also per-repo if people don't want to configure it via an ~/.ssh/config file) as users may have different keys for different repos/work domains/other domains

  12. cicorias commented on Apr 15, 2018

    @cicorias

    Can an option be added when I click on the use desktop from the GitHub repo "clone" action that says "Use ssh - ONLY IF YOU KNOW WHAT YOU"RE DOING"...

    Just a pain. I love the "just click clone" flow for checking things out. But to push I have to update the origin via git remote set-url... command - or use the Desktop settings and just paste it in. Minor but I look a a lot of code..

  13. chrisrapson commented on Jul 18, 2018

    @chrisrapson

    @thenetimp (or anyone else) I don't suppose you know the workaround for github desktop refusing to push using a password protected ssh key in windows do you? When I run ssh-add in gitbash, I get Could not open a connection to your authentication agent.

  14. mcmonkey4eva commented on Jul 18, 2018

    @mcmonkey4eva

    @chrisrapson you have to do eval $(ssh-agent -s) first to start up the ssh agent - GitHub Desktop currently will not make use of it, but you can start it up, then use the ssh-add, then pull/push within the git bash terminal.

  15. 19 remaining items

  16. h8nor commented on Jun 25, 2021

    @h8nor

    It's amazing in Github Desktop x32 of latest version ssh-agent has always been launched, which could be checked by the command ssh-add -l. Terminal and Github Desktop easily picked up ssh-agent.

    After Github Desktop x64 necessary to install the git with terminal separately (it has a useless script start-ssh-agent.cmd for Windows) and indicate the path to it. Terminal works only, the app doesn't react at all. To work in terminal needs script ~/.profile that ssh-agent closes along with terminal.

    SSHAGENT=/usr/bin/ssh-agent
    SSHID=~/.ssh/id_rsa
    
    proc=$(git config --get remote.origin.url)
    if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ] && [ "${proc::4}" != "http" ]; then
    	eval $(ssh-agent -a ~/.ssh-agent.$$) && ssh-add "$SSHID"
    	trap "kill $SSH_AGENT_PID" 0
    fi
    unset SSHID SSHAGENT

    There are comments pass is stored in an open form, so no longer saved (including Windows).
    If so OpenSSH_8.x is an isolated app, Githab Desktop will not be able to work with ssh.

  17. EasyArray commented on Jul 20, 2021

    @EasyArray

    I'm trying to use GitHub Desktop with a repository on a server at my university. This server does not have an https url (so I need ssh) but it also does not allow key authentication. You have to enter a password every time you ssh there. Is there any way to set up GitHub Desktop to work with this repository? Thanks!

  18. steveward commented on Aug 17, 2021

    @steveward
    Contributor

    Thanks to the work of @sergiou87 we'll be shipping improved SSH support in GitHub Desktop. We would love for anyone in this thread who was encountering SSH issues to test it out by installing the Windows beta version. Let us know if you run into problems!

  19. hardysim commented on Aug 18, 2021

    @hardysim

    I've tried the current windows beta (2.9.1-beta4 x64) and it ask for the ssh key password right when opening it (and I checked the "save password" checkbox). But when trying to fetch something, I get the usual "Authentication failed" error dialog. I've tried using "system OpenSSH" in the settings but neither with or without it I get the same error.

  20. sergiou87 commented on Aug 18, 2021

    @sergiou87
    Member

    @hardysim thank you for your feedback! Could you share your logs with me after getting that error so I can see why exactly?

  21. hardysim commented on Aug 18, 2021

    @hardysim

    Sure:

    2021-08-18T08:11:49.213Z - info: [ui] [AppStore] loading 1 repositories from store
    2021-08-18T08:11:49.214Z - info: [ui] [AppStore] found account: shardt (Simon Hardt)
    2021-08-18T08:11:49.488Z - info: [ui] [BranchPruner] Last prune took place in a day - skipping
    2021-08-18T08:11:49.509Z - info: [ui] launching: 2.9.1-beta4 (Windows 10.0.19043)
    2021-08-18T08:11:49.511Z - info: [ui] execPath: 'C:\Users\Simon\AppData\Local\GitHubDesktop\app-2.9.1-beta4\GitHubDesktop.exe'
    2021-08-18T08:12:00.851Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: android-ecare - shardt (has token)
    2021-08-18T08:12:01.614Z - error: [ui] `git -c credential.helper= fetch --progress --prune --recurse-submodules=on-demand origin` exited with an unexpected code: 128.
    stderr:
    [email protected]: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    (The error was parsed as 2: 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 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.)
    

    I have a feeling that it does not use the ssh key at all. I've removed GitHub Desktop and reinstalled but it did not ask for the ssh key password again.

  22. sergiou87 commented on Aug 18, 2021

    @sergiou87
    Member

    it did not ask for the ssh key password again

    That's because the key password is stored in the credentials manager. I wonder… is it possible you entered the wrong password for the SSH key? I just realized we're not handling that scenario properly, and the wrong password might be kept 🤦‍♂️

    I'll look into that, meanwhile you can open the Credential Manager on Windows, and on Windows Credentials, look for GitHub - SSH key passphrases and delete that entry. The app should prompt you the key password again.

  23. hardysim commented on Aug 18, 2021

    @hardysim

    Ahh here we go. Yes, it was wrong. After removing it from windows GitHub Desktop asks for it again and using the correct password, it fetches just fine. So please add a better handling when saving a wrong password and we're good to go.

  24. sergiou87 commented on Aug 18, 2021

    @sergiou87
    Member

    @hardysim we have improved that behavior in #12800 and now it should only store good passwords. Those improvements are available in the latest beta 2.9.1-beta6

    However, beware, we found an edge case where a certain combination of “remember passphrase” and “don’t remember passphrase” + bad password and good password, could cause the bad password to be stored. I'll tackle that one tomorrow!

    Thank you again for your feedback! ❤️ 🙇‍♂️

  25. sergiou87 commented on Aug 24, 2021

    @sergiou87
    Member

    This should be much better now with the release of GitHub Desktop 2.9.1 today 😄

    Therefore, we decided to close this issue and start again with new issues found in its current state.

    Thanks everyone for your help and patience! ❤️

  26. ajtruckle commented on May 20, 2022

    @ajtruckle

    I am completely and utterly confused.

    • I created keys manually.
    • I created keys with PuttyGen.
    • I converted to PPK.
    • I added to Putty Pageant.

    In each case the files are no own names and in my own directories and with passphrase.

    • I added the public key to my GitHub settings.
    • I try to sync with GitHub desktop - says I am not signed in even though I am.

    I have to use the HTTPS route.

    Why? Please help. Confused out my mind.

  27. steveward commented on May 24, 2022

    @steveward
    Contributor

    @ajtruckle I would recommend using Git for Windows instead of PuTTY and following the specific steps in this help article to get SSH working:

    https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

    Make sure ssh-agent is running and your key has been added.

  28. ajtruckle commented on May 24, 2022

    @ajtruckle

    Hi @steveward Eventually I was given some help on StackOverflow:
    https://stackoverflow.com/q/72345710/2287576
    As you say, it was easier to move over to using SSH in the settings.
    I eventually found out how to add the ssh-agent service and configure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions