推送到现有项目的 SSH 错误权限被拒绝(公钥) [英] SSH error on push to an existing project Permission denied (publickey)
问题描述
完成了使用 GitLab 的所有必要步骤,这些设置是:
- 按照此链接 中的描述创建了 rsa
- 复制在
{my key}.pub
中生成的代码并将此代码添加到 GitLab - 在我现有的存储库中,使用命令
git remote add gitlab git@gitlab.com:ridermansb/breezenhibernateproblem.git
- 我试着推送
git push -u gitlab master
我的 .ssh/config
主机 gitlab.com主机名 gitlab.com身份文件 C:UsersRiderman.sshgitlab_rsa身份只有是
以下错误:
警告:将gitlab.com,54.243.197.170"(RSA)永久添加到已知主机列表中.权限被拒绝(公钥).致命:无法从远程存储库读取.
请确保您拥有正确的访问权限并且存储库存在.
我制作了一个视频,展示了所有步骤:http://www.screenr.com/euVH
我做错了什么?
在看到你的截屏视频后,我看到您没有 %HOME%.sshconfig
文件.
这很重要,因为:
- 默认情况下,ssh 将在
%HOME%.sshid_rsa(.pub)
中查找公钥/私钥 - 使用类似 scp 的语法(
git@gitlab.com:yourRepo
,使用:
"作为分隔符),ssh 可以查看.ssh/config
文件用于实际公钥/私钥的位置,使用gitlab.com
作为所述config
文件中的条目.
添加%HOME%.sshconfig
:
主机 gitlab.com主机名 gitlab.com身份文件 C:path o.sshgitlab_rsa身份只有是
并且您的 git push -u gitlab master
将起作用.
事实证明这也是关于正确设置HOME:><块引用>
%HOME%
不正确.
我将变量 %HOME%
配置为在本地指向 %USERPROFILE%
并且它工作了
Mysygit 确实设置了 HOME,但如果您在 git-cmd
session,那么你有责任正确设置HOME
.
Made all necessary steps to use the GitLab, these settings are:
- Created a rsa as described in this link
- Copied the code generated in
{my key}.pub
and added this code in GitLab - In my existent repository added to url with command
git remote add gitlab git@gitlab.com:ridermansb/breezenhibernateproblem.git
- I tried to make the push
git push -u gitlab master
My .ssh/config
Host gitlab.com
HostName gitlab.com
IdentityFile C:UsersRiderman.sshgitlab_rsa
IdentitiesOnly yes
Error below:
Warning: Permanently added 'gitlab.com,54.243.197.170' (RSA) to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I made a video showing all the steps: http://www.screenr.com/euVH
What am I doing wrong?
After seeing your screencast, I see that you don't have a %HOME%.sshconfig
file.
This is important because:
- by default, ssh will look for the public/private key in
%HOME%.sshid_rsa(.pub)
- With an scp-like syntax (
git@gitlab.com:yourRepo
, with the ':
' as separator), ssh could look in a.ssh/config
file for the location of the actual public/private key, usinggitlab.com
as an entry in saidconfig
file.
Add %HOME%.sshconfig
with:
Host gitlab.com
HostName gitlab.com
IdentityFile C:path o.sshgitlab_rsa
IdentitiesOnly yes
and your git push -u gitlab master
will work.
It turned out it was also about setting HOME correctly:
%HOME%
was not correct.
I configured the variable%HOME%
to point to%USERPROFILE%
locally and it worked
Mysygit does set HOME, but if you are using git outside of a git-cmd
session, then it is your responsibility to set HOME
correctly.
这篇关于推送到现有项目的 SSH 错误权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!