Skip to content

ssh-agent broken in 2.51.0 for users with space in username #5893

Closed

Description

@jeffmaury

Existing issues matching what you're seeing

  • I was not able to find an open or closed issue matching what I'm seeing

Git for Windows version

2.51.0

Windows version

Windows 11

Windows CPU architecture

x86_64 (64-bit)

Additional Windows version information

Options set during installation

Installed through winget

Other interesting things

No response

Terminal/shell

bash

Commands that trigger the issue

eval `ssh-agent -s`
ssh-add

Expected behaviour

You should be able to provide credentials

Actual behaviour

Error message claiming the socket cannot be accessed

Repository

No response

Activity

  1. dscho commented on Oct 20, 2025

    @dscho
    Member

    Error message claiming the socket cannot be accessed

    Please refrain from such vague reports. If there is an error message, you need to paste it (if there is anything sensitive, you need to redact it of course). Handwaving bug reports are frustrating and therefore counterproductive.

  2. jeffmaury commented on Oct 20, 2025

    @jeffmaury
    Author

    Output of eval ssh-agent -s is:

    bash: Maury/.ssh/agent/s.acw9j72LaJ.agent.xpSaqihvTw: No such file or directory
    Agent pid 78
    

    where my home folder is C:\Users\Jeff Maury

    Then running ssh-add:

    Could not open a connection to your authentication agent.

  3. dscho commented on Oct 20, 2025

    @dscho
    Member

    Okay, let's pinpoint this further: Does the same happen with a regular MSYS2 (after installing ssh with pacman -Sy openssh and specifically overriding the home directory by prefixing the db_home line in /etc/nsswitch.conf with env so that it looks like the one of Git Bash's)?

  4. dscho commented on Oct 20, 2025

    @dscho
    Member

    Also, how certain are you that you quoted ssh-agent -s in eval "$(ssh-agent -s)"?

  5. jeffmaury commented on Oct 20, 2025

    @jeffmaury
    Author

    Also, how certain are you that you quoted ssh-agent -s in eval "$(ssh-agent -s)"?

    I used back quote in the .bashrc script and not double quotes. It worked and started to break with 2.51.0. Noticed the agent socket was on /tmp before and is now under $HOME with 2.51.0

  6. jeffmaury commented on Oct 20, 2025

    @jeffmaury
    Author

    Okay, let's pinpoint this further: Does the same happen with a regular MSYS2 (after installing ssh with pacman -Sy openssh and specifically overriding the home directory by prefixing the db_home line in /etc/nsswitch.conf with env so that it looks like the one of Git Bash's)?

    Yes same erros happen

  7. dscho commented on Oct 20, 2025

    @dscho
    Member

    Noticed the agent socket was on /tmp before and is now under $HOME with 2.51.0

    That is indeed new, it is a change introduced in OpenSSH. It is discussed (among other places) here.

    So you have two options: either use the -a option of ssh-agent (opening yourself up to what's commonly known as "relative path attacks"), or surround your back-ticked ssh-agent invocation with double quotes (as is actually recommended in a lot of places on the internet).

  8. dscho commented on Oct 20, 2025

    @dscho
    Member

    And if you were following the guidance provided at https://gitforwindows.org/auto-launching-ssh-agent-when-git-starts.html#manually, it would be a really nice thing if you could open a PR to fix that.

  9. jeffmaury commented on Oct 20, 2025

    @jeffmaury
    Author

    Noticed the agent socket was on /tmp before and is now under $HOME with 2.51.0

    That is indeed new, it is a change introduced in OpenSSH. It is discussed (among other places) here.

    So you have two options: either use the -a option of ssh-agent (opening yourself up to what's commonly known as "relative path attacks"), or surround your back-ticked ssh-agent invocation with double quotes (as is actually recommended in a lot of places on the internet).

    Double quotes do not resolve the issue:I tried eval "$(ssh-agent -s)" but got the same error beccause it seems eval cannot process:

    SSH_AUTH_SOCK=/c/Users/Jeff Maury/.ssh/agent/s.acw9j72LaJ.agent.zwtScelcZJ; export SSH_AUTH_SOCK;

    which is the first line generated by ssh-agent -s

  10. jeffmaury commented on Oct 20, 2025

    @jeffmaury
    Author

    And if you were following the guidance provided at gitforwindows.org/auto-launching-ssh-agent-when-git-starts.html#manually, it would be a really nice thing if you could open a PR to fix that.

    Seems changing from ssh-agent -s to ssh-agent -T does the trick, let me know if you want me to provide a PR for the documentaiton

  11. dscho commented on Oct 20, 2025

    @dscho
    Member

    And if you were following the guidance provided at gitforwindows.org/auto-launching-ssh-agent-when-git-starts.html#manually, it would be a really nice thing if you could open a PR to fix that.

    Seems changing from ssh-agent -s to ssh-agent -T does the trick, let me know if you want me to provide a PR for the documentaiton

    Yes, please!

  12. dscho commented on Oct 21, 2025

    @dscho
    Member

    Thank you for git-for-windows/git-for-windows.github.io#80! Is there anything else you would need here? Otherwise I think we can close this, as it is really an OpenSSH bug that it does not quote the path in the eval'able output of ssh-agent.

  13. jeffmaury commented on Oct 22, 2025

    @jeffmaury
    Author

    Thank you for git-for-windows/git-for-windows.github.io#80! Is there anything else you would need here? Otherwise I think we can close this, as it is really an OpenSSH bug that it does not quote the path in the eval'able output of ssh-agent.

    Yes I think we can

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions