GitLab + Eclipse + SSH - “身份验证失败”或“无法打开 git-upload-pack”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21015255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:33:40  来源:igfitidea点击:

GitLab + Eclipse + SSH - "Auth failed" or "cannot open git-upload-pack"

eclipsegitauthenticationsshgitlab

提问by lippoliv

This week I set up an new GitLab server. It is running.
Yesterday I forced him to be reachable via HTTPS for secure communication.

本周我设置了一个新的 GitLab 服务器。它正在运行。
昨天我强迫他可以通过 HTTPS 访问以进行安全通信。

In Eclipse I generated an RSA-Key via the preferences.

在 Eclipse 中,我通过首选项生成了一个 RSA-Key。

But if I try to import an Git-Project (git@DOMAIN:GROUP/PROJECT.git) then:

但是如果我尝试导入一个 Git-Project ( git@DOMAIN:GROUP/PROJECT.git) 那么:

  1. without password filled in, I got the response: Auth fail: Invalid password or missing SSH key.
  2. with my password filled in (but git username), I got the response:

    Auth fail: Invalid password or missing SSH key.
    
  3. with my user & password, I got the response:

    Auth fail: Invalid password or missing SSH key.
    
  1. 没有填写密码,我得到了响应:身份验证失败:密码无效或缺少 SSH 密钥。
  2. 填写我的密码(但 git 用户名),我得到了回应:

    Auth fail: Invalid password or missing SSH key.
    
  3. 使用我的用户和密码,我得到了回应:

    Auth fail: Invalid password or missing SSH key.
    

Via HTTPS I get the response:

通过 HTTPS 我得到响应:

cannot open git-upload-pack

Please, what do I don't see?

拜托,我看不到什么?

回答by VonC

httpsand sshare two different communication protocols.

httpsssh是两种不同的通信协议。

If you want to access your GitLab repos with https url, you should use https url:

如果要使用 https url 访问 GitLab 存储库,则应使用 https url:

https://yourLogin@DOMAIN/group/project.git

If you are using git@DOMAIN:GROUP/PROJECT.git, it is an ssh url.

如果您使用的是 git@DOMAIN:GROUP/PROJECT.git,则它是一个 ssh url。

Now: ssh cloning should work provided you have correctly setup your SSH id_rsaand id_rsa.pubin your Eclipse: see EGit SSH configuration.
Make sure:

现在:ssh 克隆应该可以工作,前提是您已正确设置 SSHid_rsaid_rsa.pub在 Eclipse 中:请参阅EGit SSH 配置
确保:

  • your private key isn't password protected at first.
  • your public key (id_rsa.pub) is published on your GitLab profile
  • 您的私钥起初不受密码保护。
  • 您的公钥 ( id_rsa.pub) 已发布在您的 GitLab 个人资料中

回答by JohnRossy

Recently, I did have similar issues with GitLab but fixed it with:

最近,我确实在 GitLab 上遇到了类似的问题,但通过以下方式修复了它:

First, I generated the ssh-rsa by using the MAC-OSX CLI and exported to GitLab. Git CLIs were working but no luck from Eclipse.

首先,我使用 MAC-OSX CLI 生成了 ssh-rsa 并导出到 GitLab。Git CLI 正在运行,但 Eclipse 没有运气。

Then, I went to Eclipse > Preferences... > General > Network Connections > SSH2, Key Management tab, I regenerated the key from Eclipse but using the "Generate RSA key..." button. It had "RSA-1024" at the end, and exported to GitLab.

然后,我转到 Eclipse > 首选项... > 常规 > 网络连接 > SSH2,密钥管理选项卡,我从 Eclipse 重新生成了密钥,但使用了“生成 RSA 密钥...”按钮。它以“RSA-1024”结尾,并导出到 GitLab。

回答by Bahadir Tasdemir

From my answer from here:

从我从这里的回答:

I faced the same issue while migrating my project from github to bitbucket and this is how I resolved it:

我在将我的项目从 github 迁移到 bitbucket 时遇到了同样的问题,这是我解决的方法:

Introduction: I will describe the ssh key usage here. A user generates a unique key to connect to remote machines using ssh. So you can create it locally. After, user uploads the keys to the remote machines where want to connect without password and more securely. On Git, the same thing happens, user creates a ssh key and uploads the generated key value to the git system providers like Github or Birbucket. After uploading your unique key, you must configure your development environment to let your git system provider communicate providing security over ssh key.

介绍:我将在这里描述 ssh 密钥的用法。用户生成一个唯一的密钥以使用 ssh 连接到远程机器。所以你可以在本地创建它。之后,用户将密钥上传到想要无需密码且更安全地连接的远程机器。在 Git 上,同样的事情发生,用户创建一个 ssh 密钥并将生成的密钥值上传到 git 系统提供商,如 Github 或 Birbucket。上传您的唯一密钥后,您必须配置您的开发环境,让您的 git 系统提供商通过 ssh 密钥提供安全性进行通信。

1) I was using ssh key to push my commits to remote with github in eclipse, the ssh key is set at window -> preferences -> General -> Network Connections -> SSH2for eclipse (on git pushes, this ssh key is used if set). If you do not have any ssh keys on your machine then follow this articleto generate one for you and set it into eclipse at the path above.

1) 我在 eclipse 中使用 ssh 密钥通过 github 将我的提交推送到远程,ssh 密钥设置window -> preferences -> General -> Network Connections -> SSH2为 eclipse (在 git pushes 上,如果设置了这个 ssh 密钥,则使用)。如果您的机器上没有任何 ssh 密钥,请按照本文为您生成一个并在上面的路径中将其设置到 eclipse 中。

2) In your github or bitbucke account, find the screen where you can save your ssh key. For bitbucket, it is at https://bitbucket.org/account/user/[user-name]/ssh-keys/. '[user-name]' here is your user name at bitbucket. Open your 'id_dsa.pub' file (where you generated your ssh key) with a text editor, select all, copy and paste into your github/bitbucket accounts' ssh key addition section and then click add.

2) 在您的 github 或 bitbucke 帐户中,找到可以保存 ssh 密钥的屏幕。对于 bitbucket,它位于https://bitbucket.org/account/user/[user-name]/ssh-keys/。'[user-name]' 这里是你在 bitbucket 的用户名。使用文本编辑器打开“id_dsa.pub”文件(在其中生成 ssh 密钥),全选,复制并粘贴到您的 github/bitbucket 帐户的 ssh 密钥添加部分,然后单击添加。

3) At eclipse, be sure to use the 'ssh' GIT URI for your project. Go to Window -> Preferences -> Team -> Git -> Configuration, click 'Repository Settings' tab and paste your GIT ssh URI to remote.origin.url.

3) 在 eclipse 中,确保为您的项目使用“ssh”GIT URI。转到Window -> Preferences -> Team -> Git -> Configuration,单击“ Repository Settings”选项卡并将您的 GIT ssh URI 粘贴到remote.origin.url.

Bitbucket ssh uri selection

Bitbucket ssh uri 选择

4) Finally try to push your commits to remote. You mustn't face any errors, if you have please comment under my answer.

4)最后尝试将您的提交推送到远程。你不能面对任何错误,如果你有,请在我的回答下发表评论。

Regards...

问候...