Skip to content

Windows only - Git ssh passphrase not remembered #12401

Open

Description

@jonvanausdeln

System details

RStudio Edition : Desktop
RStudio Version : 2022.12.0+353
OS Version      : Windows 11
R Version       : any

Steps to reproduce the problem

  1. Setup ssh key with passphrase for git/github
  2. Start new project with Git
  3. When prompted for passphrase check "Remember passphrase for this session"
  4. Do a git pull

image

Describe the problem in detail

Prompted for passphrase for every git operation

Describe the behavior you expected

Passphrase to be remembered (with checkbox selected to remember)

This is only on windows. I behaves as expected on MacOS and Linux

  • [x ] I have read the guide for submitting good bug reports.
  • [ x] I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • [ x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    vcs
    new
    on Dec 6, 2022
  2. added this to the Backlog-1 milestone on Dec 6, 2022
  3. jonvanausdeln commented on Dec 6, 2022

    @jonvanausdeln
    Author

    This happens both in the git pane and in terminal.

  4. removed this from the Backlog-1 milestone on Dec 6, 2022
  5. added and removed
    new
    on Dec 6, 2022
  6. kevinushey commented on Dec 7, 2022

    @kevinushey
    Collaborator

    RStudio tries to use the SSH agent to remember keys here, e.g.

    if (input.remember)
    {
    ensureSSHAgentIsRunning();
    addKeyToSSHAgent(keyFile, passphrase);
    }

    Presumedly something is going wrong here? Do you see any errors in the logs?

  7. jonvanausdeln commented on Dec 7, 2022

    @jonvanausdeln
    Author

    Yes, there is now that I checked.

    ERROR Error connecting to agent: No such file or directory; LOGGED FROM: void __cdecl rstudio::session::modules::git::`anonymous-namespace'::addKeyToSSHAgent_onCompleted(const struct rstudio::core::system::ProcessResult &) C:\Users\jenkins\workspace\ide\open-source-pipeline\elsbeth-geranium\src\cpp\session\modules\SessionGit.cpp:2590

  8. jonvanausdeln commented on Dec 7, 2022

    @jonvanausdeln
    Author

    I also just checked Spotted Wakerobin and get the same issue.

  9. kevinushey commented on Dec 8, 2022

    @kevinushey
    Collaborator

    I wonder if the problem here is that the path to the key file you're seeing is a MinGW path (/c/Users/Jon/.ssh/id_ed25519; note the /c/ prefix rather than C:/`).

    Setup ssh key with passphrase for git/github

    Can you confirm the steps you used to set up the key?

    I also sort of wonder if this is a PATH issue; e.g. perhaps the wrong version of ssh-add or ssh-agent is being invoked here. Can you share the output of:

    echo $PATH
    which ssh-add
    which ssh-agent
    

    from an RStudio terminal?

    The version of Git Bash installed may also be helpful.

  10. mikebessuille commented on Dec 12, 2022

    @mikebessuille
    Contributor

    https://apple.stackexchange.com/a/250572/324264 provides some ideas on how to fix this in the OS. We need to do a bunch of fixes to our Git client - will be after we fix Data Viewer, fixing plot problems,...

  11. added this to the Backlog-2 milestone on Dec 12, 2022
  12. 5 remaining items

  13. removed this from the Later milestone on Mar 20, 2024
  14. jonvanausdeln commented on Mar 21, 2024

    @jonvanausdeln
    Author

    Looks like I forgot to answer a question from before. I originally setup my ssh keys with either windows cmd or powershell. I know I didn't use git-bash.

  15. jthomasmock commented on Mar 27, 2024

    @jthomasmock
    Contributor

    We can do an exploration for Cranberry Hibiscus. 🕐 + 🗳 + 🔎

  16. gtritchie commented on Oct 20, 2024

    @gtritchie
    Member

    I suspect the problem is the presence of multiple ssh implementations (e.g. the one in Windows and the one in Git for Windows).

    The below describes the problem we are seeing: "Otherwise you might be asked to introduce the passphrase on each git command call that connects to a remote repository."

    https://github.com/git-for-windows/git/wiki/FAQ#running-without-git-bash

    If you choose to use OpenSSH that comes with git during installation (default option) and wish to work from Windows' Command Prompt (cmd) or PowerShell instead of Git Bash you should make sure:

    1. You're calling the correct executables.
      Windows comes with a different OpenSSH distribution and by default you might be calling it while git commands use its own. Set the environment PATH to use the git installation ssh commands first, those are usually at C:\Program Files\Git\usr\bin.
      In CMD: set PATH=C:\Program Files\Git\usr\bin;%PATH%
      In PowerShell: $Env:PATH = "C:\Program Files\Git\usr\bin;$Env:PATH"
      This will make sure, for example, that you add the private keys to the correct ssh-agent service when calling ssh-add. Otherwise you might be asked to introduce the passphrase on each git command call that connects to a remote repository.

    2. Git's ssh is able to connect to the ssh-agent.
      In order to connect to the ssh-agent service, git's ssh needs to know how. This is accomplished by two environment variables called SSH_AGENT_PID and SSH_AUTH_SOCK. Luckily, there is a convenient script start-ssh-agent.cmd included with the git installation you can call to set this up. The values are dynamic and only valid after calling the script. Forgetting to set them will fail silently, so be sure to call the script each time you open a new command prompt.

    Our code currently sets SSH_AGENT_PID but does not set SSH_AUTH_SOCK. We probably need to tweak paths to ensure we're using the git ssh, and set that other env var.

    Also curious if it's possible to use the Windows ssh implementation with the git for windows ssh-agent. If so, we might need to let the user configure which ssh they want to use.

  17. gtritchie commented on Oct 28, 2024

    @gtritchie
    Member

    We would really like to fix this but not going to have time in this release. Bumping yet again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugvcswindows

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions