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

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

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

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

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


当前回答

我在Windows 10上使用Pageant作为SSH代理,除了向Windows添加一个环境变量(翻译自德语Windows 10,所以命名可能不同):

搜索“变量” 打开系统环境变量 单击底部的环境变量按钮 添加一个名为“GIT_SSH”的新密钥和值“C:\Program Files\PuTTY\plink.exe”,到顶部的“用户变量xxx”部分 做完了。

感谢Benjamin Bortels,来源:https://bortels.io/blog/git-in-vs-code-unter-windows-richtig-einstellen

其他回答

转到终端,重新生成ssh密钥。ssh - keygen类型。它会问你想保存在哪里,输入路径。

然后将公钥复制到gitlabs平台。它通常从ssh-rsa开始。

在我的例子中,在更新到12.9.2之后,我需要更新我的sshd_config文件以使用Authorized command keys指令。

这里的文档解释了一切: https://docs.gitlab.com/ee/administration/operations/fast_ssh_key_lookup.html

当我重新启动ssh时,密钥完美地工作了。

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

修改权限::chmod 400 ~/.ssh/id_rsa 这对我很有帮助。

我在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

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