我的问题是我不能从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)修复了这个问题。

其他回答

对于任何使用Windows 10且没有其他工作的人:

在我的情况下,我不得不用https而不是ssh克隆回购,并弹出一个窗口,要求我的凭证。 在那之后一切都很好。

在我的案例中,它在WSL (Linux的Windows子系统)中不起作用。

当我开始WSL时,我必须

启动ssh-agent_ eval $(ssh-agent -s) 将密钥添加到ssh-agent: ssh-add ~/.ssh/id_rsa 如果有提示,请输入密码

现在连接起作用了。 我们可以使用ssh -T git@github.com进行测试

注:

weasel-pageant允许我们在WSL中重用在PuTTY pageant中加载的ssh密钥 详细解释:Git通过SSH从Windows返回Permission Denied

我在gitlab help中找到了解决方案。

To create a new SSH key pair: 
 1. Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
 2. Generate a new ED25519 SSH key pair: ssh-keygen -t ed25519 -C "email@example.com"
 2.1 Or, if you want to use RSA: ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
 3. Next, you will be prompted to input a file path to save your SSH key pair to... use the suggested path by pressing Enter
 4. Once the path is decided, you will be prompted to input a password to secure your new SSH key pair. It's a best practice to use a password, but it's not required and you can skip creating it by pressing Enter twice.
 5. Copy your public SSH key to the clipboard by using one of the commands below depending on your Operating System:
        macOS:        pbcopy < ~/.ssh/id_ed25519.pub
        WSL / GNU/Linux (requires the xclip package):      xclip -sel clip < ~/.ssh/id_ed25519.pub
        Git Bash on Windows:      cat ~/.ssh/id_ed25519.pub | clip
 6. Navigating to SSH Keys and pasting your public key in the Key field
 7. Click the Add key button

我希望它能帮助到你们中的一些人!

这两种访问git存储库的方式之间似乎存在差异,即使用SSH或HTTPS。对我来说,我遇到这个错误是因为我试图使用SSH推送我的本地存储库。

这个问题可以简单地通过单击项目登录页面上的克隆按钮来解决,复制HTTPS链接并将其替换为格式为“git@gitlab...”的SSH链接。

我也有同样的问题,我通过添加一个新的ssh密钥来解决它:

ssh-keygen -t ed25519 -C "email@example.com" 将您的公共SSH密钥复制到剪贴板(xclip -sel clip < ~/. SSH /id_ed25519. exe)。pub在我的情况下在Linux上) 在gitlab上,转到settings=>ssh keys,然后跳过新密钥