我尝试将ssh密钥添加到我的GitLab帐户中,以便通过npm使用它。
我遵循了https://docs.gitlab.com/ee/ssh/的指导,成功地将我的密钥添加到了账户中。
ssh -T git@gitlab.com
发送消息欢迎来到Gitlab,用户名工作正常。
但是ssh -T ssh://git@gitlab.com
无法工作并显示以下错误信息:
权限被拒绝(publickey)。
当我在我的Node项目上运行npm install
时,在package.json
文件中添加我的Node模块作为依赖项,返回以下错误:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@gitlab.com/myproject/myproject.git
npm ERR!
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.
npm ERR!
npm ERR! exited with error code: 128
我在
package.json
中添加了以下依赖项:"my-project": "git@gitlab.com:myproject/myproject.git",
我对ssh和密钥配对不太熟悉,如果有人能告诉我我的配置出了什么问题,那将帮助我很多,谢谢。