2

What I have

  • Private GitHub repository: a NodeJS private module/package.
  • SSH private-public keys created with ssh-keygen:
    • Private key stored at C:\Users\USER\.ssh\id_rsa.
    • Public key added to GitHub.

What I want

To install the private module (hosted on GitHub) using:

  • npm install
  • SSH public-private authentication (in particular, using the id_rsa SSH private key saved in C:\Users\USER\.ssh).

What happen

When I execute:

npm install git@github.com:USER/REPO.git --save

the following popup is shown:

enter image description here

I want to avoid this popup. Instead, the id_rsa SSH private key password must be request.

If I execute a command using git utility like this:

git clone git@github.com:USER/REPO.git

the SSH private key is used:

Cloning into 'REPO'...
Enter passphrase for key '/c/Users/USER/.ssh/id_rsa':
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 20 (delta 4), reused 20 (delta 4), pack-reused 0
Receiving objects: 100% (20/20), done.
Resolving deltas: 100% (4/4), done.

Environment

  • Windows 10 Pro 21H1 19043.1526
  • NodeJS 16.13.1
  • NPM 7.19.1
cespon
  • 5,630
  • 7
  • 33
  • 47

1 Answers1

1

you must understand where your git config file lives https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Where-system-global-and-local-Windows-Git-config-files-are-saved

after you have identified where your .gitconfig file lives give it values similar to below

[user]
    email = myemail@example.com
    name = My Name John Doe
[color]
    ui = true
[push]
    default = simple
[alias]
    co = checkout

[url "ssh://git@github.com/"]
    insteadOf = https://github.com/


[core]
    sshcommand=ssh -i ~/.ssh/my_ssh_key_name

[pull]
    rebase = false

then save above gitconfig file ... assure you update above with actual values especially the location of your ssh key file

now engage your ssh key by issing

ssh-add ~\.ssh\my_ssh_key_filename

for further details see https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement

also read this Using GIT_SSH_COMMAND in Git for Windows

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104