我尝试在我的GitLab帐户中添加一个ssh密钥,以便通过npm使用它.
我在https://docs.gitlab.com/ee/ssh/之后添加了我的密钥.
ssh -T git@gitlab.com
Run Code Online (Sandbox Code Playgroud)
工作正常并发送消息欢迎使用Gitlab,用户名.
但是ssh -T ssh://git@gitlab.com
没有工作,并给我这个错误信息:
权限被拒绝(publickey).
当我npm install
在我的节点项目上运行时,我将节点模块作为依赖项添加到package.json
文件中,它返回以下错误:
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
Run Code Online (Sandbox Code Playgroud)
我在里面添加了我的依赖package.json
,如下:
"my-project": "git@gitlab.com:myproject/myproject.git",
Run Code Online (Sandbox Code Playgroud)
我对ssh和键配对感到不舒服,如果有人能告诉我配置有什么问题,它会对我有很大帮助,谢谢.
被以下行误导(谈论自己)有点好笑:
ssh -T ssh://git@gitlab.com
Run Code Online (Sandbox Code Playgroud)
该命令实际上并不期望一个协议前缀,而是一个前缀或不是用户名后跟一个arobase的主机名,如手册页所述:
ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] [-D [bind_address:] port] [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file] [ -J [user @] host [:port]] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R地址] [-S ctl_path] [-W host:port] [-w local_tun [:remote_tun]] [user @] hostname [command]
在这里,它实际上ssh://git
是一个用户名.这就是为什么它不会登录,因为您连接的用户名必须是git
,而不是ssh://git
.
归档时间: |
|
查看次数: |
118 次 |
最近记录: |