有没有办法指定哪个ssh密钥应该用于npm安装 [英] Is there a way to specify which ssh key should be used for npm install

查看:217
本文介绍了有没有办法指定哪个ssh密钥应该用于npm安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 private-module:

我有一个私人回购,我想要在我的package.json文件中安装。 git + ssh://git@bitbucket.org:private / private-module.git

默认情况下,npm使用您的默认私钥。我希望能够在运行 npm install 时指定哪个ssh密钥npm应该使用。有没有办法做到这一点?

解决方案

以下是一些解决方案:


  • 为您的〜/ .ssh / config 添加一个条目。例如:

     
    主机bitbucket.org
    IdentityFile〜/ .ssh / bitbucket_key
    IdentitiesOnly是


  • 使用 ssh-agent 并将您的密钥事先添加到代理实例。 p>


  • 使用类似 ssh-ident 的选项来选择ssh代理以及基于当前工作目录或传递给ssh-ident的参数动态标识。正如他们的自述文件所述,您通常会将ssh-ident别名为 ssh ,以便随处自动使用它。



I have a private repo that I want to install in my package.json file.

"private-module": "git+ssh://git@bitbucket.org:private/private-module.git"

By default npm uses your default private key. I want to be able to specify which ssh key npm should use when running npm install. Is there any way to do this?

解决方案

Here are a few solutions:

  • Add an entry to your ~/.ssh/config. For example:

    Host bitbucket.org
         IdentityFile ~/.ssh/bitbucket_key
         IdentitiesOnly yes
    

  • Use ssh-agent and add your key to the agent instance beforehand.

  • Use something like ssh-ident for choosing ssh agents and identities dynamically based on the current working directory or arguments passed to ssh-ident. As their readme states, you would typically alias ssh-ident to ssh so that it's automatically used everywhere.

这篇关于有没有办法指定哪个ssh密钥应该用于npm安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆