Elias
Elias

Reputation: 4142

Npm gets stuck when installing from git with ssh

I'm trying to install a npm package from a git repository from our server. When I now do: npm i git+ssh://[email protected]/path/to/rep I get stuck at

⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session 42afea5547108748

It just stops working, no errors shown.

thanks in advance

Edit:

If I press enter rapidly I get (note line 1):

Enter passphrase for key '/Users/elias/.ssh/shop_dev': -session dfa32709de1392f7
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session dfa32709de1392f7
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session dfa32709de1392f7
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session dfa32709de1392f7
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session dfa32709de1392f7

But no response when I enter the password. Neither certificates key nor with the passphrase of the user.

Upvotes: 5

Views: 4301

Answers (2)

Aymene Bourafai
Aymene Bourafai

Reputation: 93

Had the same issue and this post of GitHub explains how to solve it very easily.

all you need is adding the following lines to this file ~/.ssh/config

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/{your private key file name}

Upvotes: 1

G. Stoynev
G. Stoynev

Reputation: 7791

Been through exactly same issue on a different OS and different bash.

Pls see this: npm install not prompting passphrase required - you can try typing your pass phrase when the hang occurs.

Or, to diagnose it another way, if you can, temporarily create and try with a key that is not password-protected. If that works, then you have to see which component acts as your ssh authentication agent (ssh-agent?).

In my case I reconfigured VSCode to use a different bash - one that I knew was playing nice with my passphrase-protected key.

Perhaps this URL will give you some pointers: Generating a new SSH key and adding it to the ssh-agent

-- Edit 1 --

In your case (MacOS) it looks like the tool you may want to look into for help with providing the interaction is sshpass (enter link description here)

-- Edit 2 --

Since you confirmed that password-less key works just fine, you have at least these three options, assuming you are doing this interactively (for scripting options are different):

  • figure out how to enter pass phrase while "hung", if possible (some people indicate it is - see the bug link above)
  • Use an agent that plays nice with your shell; that worked for me, but I didn't like having that extra "agent". Instead I opted for...
  • Reconfigure VS Code to use a different shell - one which plays nice with the password-protected key interaction. What worked for me was the bash included with my git install.

In your case (MacOS) it looks like the tool you may want to look into for help with providing the interaction is sshpass (enter link description here)

Upvotes: 3

Related Questions