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

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

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

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

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


当前回答

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

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".

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

其他回答

步骤1: 在~/中添加了一个配置文件。Ssh /config文件,看起来像

   User git
   Hostname gitlab.com
   IdentityFile ~/.ssh/id_rsa_gitlab
   TCPKeepAlive yes
   IdentitiesOnly yes

步骤2:克隆没有sudo的git repo。 文档:https://gitlab.com/help/ssh/README working-with-non-default-ssh-key-pair-paths

**有时在~/中有配置。ssh/config,但是,IdentityFile路径错误。您可以像这样检查文件名ls ~/.ssh/。gitlab的文件通常是id_ed25519。因此正确的配置是IdentityFile ~/.ssh/id_ed25519

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

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

我的问题是我使用了一个具有sudo访问权限的非root用户。但即使是sudo git克隆…没有工作。解决方案是为项目创建文件夹,chown用户项目文件夹,然后运行克隆没有sudo。

我花了好几个小时才修好的。下面的方法对我很有效。

在终端上执行这些命令。

ssh-keygen -t rsa -C "<your email address>" -b 4096 -t ed25519

将生成的密钥重命名为:id_rsa和id_rsa。将生成的公钥添加到gitlab服务器。

然后将ssh密钥添加到ssh代理,如下所示。

启动ssh-agent Eval "$(ssh-agent -s)" 如果生成的密钥名称不同,请在下面的命令中替换id_rsa ssh-add ~ / . ssh / id_rsa

要测试连接,请使用此命令。

ssh -T git@<git lab server url>

要排除故障,请使用以下命令。

ssh -Tv git@<git lab server url>
ssh -vvv git@<git lab server url>

现在可以将项目克隆到本地环境。