Phi*_*ipp 7 windows ssh powershell git permissions
我尝试通过 npm 将私有 gitlab 存储库安装到另一个节点项目。命令是npm install --save gitlab:my-project#master
This failed with
npm ERR! 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.
Run Code Online (Sandbox Code Playgroud)
我有以下设置:Windows 10、git 和 Powershell。
直接在 Powershell 中使用 git 命令工作正常,例如git pull
询问我的私钥的密码并且它工作正常。除了npm install
似乎在内部使用 git的命令之外,所有其他 git 东西都可以正常工作。
如果我使用在 Windows 上随 git 安装的 git bash,我可以运行 npm 命令并安装私有存储库。它仅在 Powershell 中失败。
尽管如此,人们可以说:使用 git bash,但我以某种方式习惯了 PowerShell。:)
权限被拒绝(公钥)。
这意味着您当前的公钥无法被远程服务器验证。
跑步:
ssh -T git@gitlab.com
Run Code Online (Sandbox Code Playgroud)
查看您的身份验证是否gitlab.com
正确。否则,请确保您已将您的帐户添加publickey
到您的 GitLab 帐户中。
git+ssh://
使用git+ssh://
, 代替git://
, 例如:
npm i -S git+ssh://git@gitlab.com/my-project/repo.git
Run Code Online (Sandbox Code Playgroud)
请参阅:从 GitLab 私有存储库安装npm
模块。
要列出您当前的身份,请运行:
ssh-add
ssh-add -L
Run Code Online (Sandbox Code Playgroud)
要添加不同的身份,请运行:ssh-add ~/.ssh/MyOtherKey.pem
npm
另外,请确保您没有将任何内容用于proxy
您的npm
. 通过检查配置npm config list
。
npm
企业您可以使用 npm Enterprise 连接到现有的身份验证系统,例如 OAuth2(适用于 GitLab)、GitHub Enterprise等。您还可以检查现有的 auth-plugin (对于 GitLab,请参阅:npme-auth-gitlab
),或编写一个用于自定义身份验证。
至于解决方法,您可以创建您的个人或 OAuth2 访问令牌(GitLab / OAuth2;GitHub / OAuth)并将其与您的私有存储库 URL 一起使用。OAuth 令牌将允许您通过 API 访问存储库,并直接通过 URL 访问个人令牌,例如
https://PERSONAL_ACCESS_TOKEN@github.com/my-project/repo
https://gitlab.com/my-project/repo?private_token=<PERSONAL_ACCESS_TOKEN>
归档时间: |
|
查看次数: |
7226 次 |
最近记录: |