推送到现有项目时出现 SSH 错误权限被拒绝(公钥) [英] SSH error on push to an existing project Permission denied (publickey)
问题描述
完成了使用 GitLab 的所有必要步骤,这些设置是:
Made all necessary steps to use the GitLab, these settings are:
- 按照此链接 中的描述创建了一个 rsa
- 复制
{my key}.pub
中生成的代码,并将此代码添加到 GitLab - 在我现有的存储库中使用命令
git remote add gitlab git@gitlab.com:ridermansb/breezenhibernateproblem.git
- 我试着做推送
git push -u gitlab master
- 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
我的 .ssh/config
My .ssh/config
Host gitlab.com
HostName gitlab.com
IdentityFile C:UsersRiderman.sshgitlab_rsa
IdentitiesOnly yes
以下错误:
警告:将 'gitlab.com,54.243.197.170' (RSA) 永久添加到已知主机列表中.权限被拒绝(公钥).致命:无法从远程存储库读取.
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.
我制作了一个展示所有步骤的视频:http://www.screenr.com/euVH
I made a video showing all the steps: http://www.screenr.com/euVH
我做错了什么?
推荐答案
看到你的截屏视频后,我看到你没有 %HOME%.sshconfig
文件.
After seeing your screencast, I see that you don't have a %HOME%.sshconfig
file.
这很重要,因为:
- 默认情况下,ssh 会在
%HOME%.sshid_rsa(.pub)
中查找公钥/私钥 - 使用类似 scp 的语法(
git@gitlab.com:yourRepo
,以 ':
' 作为分隔符),ssh 可以在中查找.ssh/config
文件用于实际公钥/私钥的位置,使用gitlab.com
作为所述config
文件中的条目.
- 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.
添加 %HOME%.sshconfig
与:
Host gitlab.com
HostName gitlab.com
IdentityFile C:path o.sshgitlab_rsa
IdentitiesOnly yes
你的 git push -u gitlab master
就可以了.
原来这也是关于正确设置HOME:
It turned out it was also about setting HOME correctly:
%HOME%
不正确.
我将变量 %HOME%
配置为在本地指向 %USERPROFILE%
并且它可以工作
%HOME%
was not correct.
I configured the variable%HOME%
to point to%USERPROFILE%
locally and it worked
Mysygit 确实设置了 HOME,但如果您在 git-cmd
session,那么你有责任正确设置HOME
.
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屋!