我的问题是我不能从GitLab中push或fetch。但是,我可以克隆(通过HTTP或SSH)。当我试图推的时候,我得到这个错误:

权限被拒绝(publickey)致命:无法从远程存储库读取

从我看过的所有线索来看,以下是我所做的:

在我的电脑上设置一个SSH密钥,并将公钥添加到GitLab 完成了用户名和电子邮件的config -global 通过SSH和HTTP克隆,以检查它是否能解决问题 执行ssh -T git@gitlab.com命令

如果您对如何解决我的问题有任何见解,我将不胜感激。


当前回答

尝试使用git克隆XXX,如果你看到LibreSSL SSL_connect: SSL_ERROR_SYSCALL连接到XXX,这可能是刚刚更新了你的操作系统,安装了一些开发工具,例如Xcode及其Mac上的工具,VPN,反病毒(特别是卡巴斯基反病毒)或其他之间的东西。

在我的情况下,简单地重新启动我的操作系统(macOS Catalina)修复了这个问题。

其他回答

当你有多个git帐户,你想要不同的ssh密钥 您必须遵循生成ssh密钥的相同步骤,但请确保 你

ssh-keygen -t ed25519 -C "your-email-id@gmail.com" 

输入您想要保存的路径(例如:my-pc/Desktop/.ssh/ed25519)

添加公钥到你的gitlab(如何添加ssh密钥到gitlab)

您必须使用下面的命令创建新的ssh标识

ssh-add ~/my-pc/Desktop/.ssh/ed25519

我找了很久才找到这个。这对我来说是完美的。

Go to "Git Bash" just like cmd. Right click and "Run as Administrator". Type ssh-keygen Press enter. It will ask you to save the key to the specific directory. Press enter. It will prompt you to type password or enter without password. The public key will be created to the specific directory. Now go to the directory and open .ssh folder. You'll see a file id_rsa.pub. Open it on notepad. Copy all text from it. Go to https://gitlab.com/-/profile/keys or Paste here in the "key" textfield. Now click on the "Title" below. It will automatically get filled. Then click "Add key".

现在试一试,肯定会管用的。

我也有同样的问题, 在我重新生成。ssh文件夹内的ssh密钥而没有命名它(保持它为id_rsa.pub)后,它已被修复。 然后再次添加到gitlab ssh key。 现在一切正常。

我也有同样的问题,在尝试了@Khan的答案后,我提出了这个问题。然而,我只能通过将.git/config文件中的原始url更改为https地址:https://gitlab.com/mygitlabusername/mygitproject.git来使其工作

由于通过ssh访问被拒绝,我发现使用https应该不是问题。但是,每次推送到at存储库时,它都会要求您提供用户名和密码

确保您没有运行sudo git克隆git@gitlab.com:project/ something .git,否则SSH将在/root/中查找。SSH,而不是您上传的密钥~/.ssh/id_rsa