推送到现有项目时出现SSH错误Permission denied(publickey) [英] 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
HostName gitlab.com
IdentityFile C:\Users\\ \\ Riderman \.ssh\gitlab_rsa
IdentitiesOnly yes
以下错误:
警告:将gitlab.com,54.243.197.170(RSA)永久添加到已知主机列表中。
权限被拒绝(publickey)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并存在存储库。
我制作了一个显示所有步骤的视频: http://www.screenr .com / euVH
我做错了什么?
看到截屏视频后,我看到您没有%HOME%\.ssh\config
文件。
这很重要,因为:
- ,ssh将在
%HOME%\.ssh\id_rsa(.pub)中查找公钥/私钥
- 使用类似scp的语法(
git@gitlab.com:yourRepo
)和<:'作为分隔符),ssh可以在 .ssh / config
文件中查找实际公钥/私钥的位置,使用gitlab.com
作为一个进入config
文件。
添加% HOME%\.ssh\config
with:
主机gitlab.com
HostName gitlab.com
IdentityFile C:\path\to\.ssh\gitlab_rsa
IdentitiesOnly yes
和你的 git push -u gitlab master
都可以。
%HOME%
不正确。
我配置了变量%HOME%
在本地指向%USERPROFILE%
并且工作
Mysygit 设置HOME ,但如果您在<$ c $之外使用git c> git-cmd 会话,那么您有责任正确设置 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:\Users\Riderman\.ssh\gitlab_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%\.ssh\config
file.
This is important because:
- by default, ssh will look for the public/private key in
%HOME%\.ssh\id_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%\.ssh\config
with:
Host gitlab.com
HostName gitlab.com
IdentityFile C:\path\to\.ssh\gitlab_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错误Permission denied(publickey)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!