我最近无法将任何更改推送到 Gitlab.com 上的任何存储库。
我知道如果您更改了 SSH 密钥或站点关闭,有时会发生这种情况,但据我所知,我没有更改目录中的任何内容~/.ssh,并且 Gitlab.com 似乎正在运行。
但是如果我运行git push我会收到错误:
You are not allowed to push code to this project.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
奇怪的是,git pull仍然有效。我还尝试重新克隆存储库、制作、提交和推送,但仍然失败。添加该--verbose选项没有显示更多细节。
我仔细检查了我的 Gitlab 帐户中文件中的 SSH 密钥是否与我文件中的文件中的密钥匹配~/.ssh/id_rsa.pub。我还尝试添加我的条目~/.ssh/config:
Host gitlab.com
IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
但这没有效果。
这里发生了什么?为什么 Gitlab 突然不接受存档的 SSH 密钥?
首先检查远程 URL ( git remote -v) 是否确实是 SSH URL ( git@gitlab:...),而不是 HTTPS URL ( https://gitlab.com/...)
在后一种情况(HTTPS)中,只有您git config credential.helper可以解释错误,因为缓存了错误的凭据(您的 GitLab 帐户的用户名/密码)
如果是前者,请尝试使用旧的 PEM 格式而不是新的 OPENSSH创建一个新的 SSH 密钥,以防 GitLab 更好地支持。
| 归档时间: |
|
| 查看次数: |
10883 次 |
| 最近记录: |