Skip to content

[BUG] Permission denied when installing a git+ssh:// dependency with key loaded by ssh-agent #3261

@remss

Description

@remss

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The npm install fails on a git+ssh:// dependency with a ssh-key loaded in ssh-agent on Windows 10 since npm 7.10.0.

Expected Behavior

The dependency should be installed correctly.

Steps To Reproduce

Start ssh-agent and add private key (using Win32-OpenSSH 8.1.0-beta installed with chocolatey)

> ssh-add -l
2048 SHA256:ed0dc338ade1bfdbaab1b5+0e5d29abd4cfd28f04c4 C:\Users\foo\Documents\private-openssh.key (RSA)
> $env:GIT_SSH
C:\Program Files\OpenSSH-Win64\ssh.exe

Install npm dependency from git+ssh:// url will fail

> npm install git+ssh://me@privatehost.com/repo#00ffe8a9e879ae7f52c066e4f4e1eed48cdbc0b4
command git --no-replace-objects ls-remote ssh://me@privatehost.com/repo
npm ERR! me@privatehost.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

Note that If I run the failed git command in my terminal it works fine

> git --no-replace-objects ls-remote ssh://me@privatehost.com/repo
24df233b1ea977d06a1e49c5d78c30cc3c8d1b4a        HEAD
24df233b1ea977d06a1e49c5d78c30cc3c8d1b4a        refs/heads/master
129da3d3b133b210bc9c7f7525b647f49bf3675a        refs/tags/v0.0.1
cf8051e20551308966116df6568866fba8f81fd4        refs/tags/v0.1.0
...

The bug appeared since npm 7.10.0 and still fails on 7.13.0. It works fine on 7.9.0 and previous version, and fine also on npm 6.14.

If I unload my key from ssh-agent, and put my key in a .ssh\id_rsa the the npm install works fine.

Environment

  • OS: Windows 10
  • Node: 12.22.1
  • npm: 7.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions