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

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

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

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

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


当前回答

这个方法对我很有用。

添加SSH / rsa密钥到gitlab Ssh-add(输入您的终端) - ssh - vt git@gitlab.com

其他回答

我的问题是,我在/etc/ssh/sshd_config下的SSH配置文件中将UsePAM从yes切换为no。有了UsePAM,一切都很完美。

步骤要做,得到同样的错误,但我修复了它。 Gitlab需要ssh-rsa,所以下面是运行ssh for rsa的代码

ssh-keygen -o -t rsa -b 4096 -C "name@gmail.com"

name@gmail.com是您的gitlab帐户电子邮件

It will prompt you to enter so just hit Enter after the below code is prompt, Enter file in which to save the key (/home/yourDesktopName/.ssh/id_rsa): It will prompt again you to enter so just hit Enter after the below code is prompt, Enter passphrase (empty for no passphrase): It will prompt again for the last you to enter so just hit Enter after the below code is prompt, Enter same passphrase again: You will show your ssh-rsa generate. Login to your Gitlab account and Go to the right navbar you will get setting and in the left sidebar you will get ssh key. Enter in it. Look above the prompt asking you to enter, you will get the path of ssh-rsa. Go to your SSH folder and get the id_rsa.pub Open it and get the key and Copy Paste to the Gitlab and you are nearly to done. Check by: ssh -T git@gitlab.com You will get: Welcome to GitLab, @joy4! Done.

创建SSH密钥后,您只需要添加公钥,通常命名为:

id_rsa . pub

OR

id_ed25519.pub

通过使用GitLab最新的工作URL:

https://gitlab.com/-/profile/keys/

我遇到这个问题是因为Windows-10上的ssh-agent冲突。 如果你也在使用Windows-10,那么请仔细阅读我的详细解决方案

如果你不在windows-10,那么请检查是否:

您的ssh代理正在运行 将正确的私钥添加到ssh-agent中 正确的公钥被添加到你的github帐户(你可以克隆,所以这一步应该是好的)

这个方法对我很有用。

添加SSH / rsa密钥到gitlab Ssh-add(输入您的终端) - ssh - vt git@gitlab.com