Issue
I am having trouble setting up nushell in windows 11 to not always ask me for the password for my ssh-key when I am using git.
I have confirmed that ssh-agent is running used ssh-add
to add my key and
ssh-add -l
shows that the correct key is indeed added. But whenever I issue a git command that would require ssh, I am asked for my password again.
Any ideas why this might be the case?
Solution
Short Version
git config --global core.sshcommand "C:/Windows/System32/OpenSSH/ssh.exe"
More Detail
I was able to reproduce this. It seems that, by default under Nushell:
In my case,
ssh-add
(andssh
) in Nushell is coming from the Windows OpenSSH implementation. I'm assuming you have the Windows OpenSSH client installed?> which ssh ssh-agent ssh-add ╭───────────┬───────────────────────────────────────────┬──────────╮ │ command │ path │ type │ ├───────────┼───────────────────────────────────────────┼──────────┤ │ ssh │ C:\Windows\System32\OpenSSH\ssh.exe │ external │ │ ssh-agent │ C:\Windows\System32\OpenSSH\ssh-agent.exe │ external │ │ ssh-add │ C:\Windows\System32\OpenSSH\ssh-add.exe │ external │ ╰───────────┴───────────────────────────────────────────┴──────────╯
On the other hand, as far as I can tell,
git
for Windows seems to default to using the Git-bash provided/usr/bin/ssh
. This requires that the environment variables are set properly by/usr/bin/ssh-agent -s
(normally eval'd into Bash or other shell). Under Git-Bash:$ which ssh ssh-agent ssh-add /usr/bin/ssh /usr/bin/ssh-agent /usr/bin/ssh-add
Since the Git-bash /usr/bin/ssh-agent
isn't available under Nushell for Windows, we need to config Git to just use the Windows OpenSSH agent directly. This can be done (reference) via:
git config --global core.sshcommand "C:/Windows/System32/OpenSSH/ssh.exe"
After I did that, git
under Nushell used my ID to access private GitHub repos.
Answered By - NotTheDr01ds Answer Checked By - Mildred Charles (WPSolving Admin)