推送到现有项目时出现SSH错误Permission denied(publickey) [英] SSH error on push to an existing project Permission denied (publickey)

查看:1052
本文介绍了推送到现有项目时出现SSH错误Permission denied(publickey)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用GitLab进行所有必要的步骤,这些设置是:


  1. 创建一个rsa,如此链接 复制在 {my key}中生成的代码。 pub 并在 GitLab 中添加此代码

  2. 在我使用 git remote add gitlab git@gitlab.com:ridermansb / breezenhibernateproblem.git
  3. 添加到我的现有库中
  4. 我试着按 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%不正确。

我配置了变量%HOME%在本地指向%USERPROFILE%并且工作


Mysygit 设置HOME ,但如果您在<$ c $之外使用git c> git-cmd 会话,那么您有责任正确设置 HOME


Made all necessary steps to use the GitLab, these settings are:

  1. Created a rsa as described in this link
  2. Copied the code generated in {my key}.pub and added this code in GitLab
  3. In my existent repository added to url with command git remote add gitlab git@gitlab.com:ridermansb/breezenhibernateproblem.git
  4. 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, using gitlab.com as an entry in said config 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆