如何解决“您正在进行身份验证的密钥已被标记为只读”?

huangapple go评论66阅读模式
英文:

How to resolve “The key you are authenticating with has been marked as read only”?

问题

无法读取远程仓库的密钥已被标记为只读。请确保您拥有正确的访问权限并且仓库存在。如何解决这个问题?

英文:

I did the following:

$ ... create new file ...
$ git add *
$ git commit -m "first-file"
$ git push origin main
...
The key you are authenticating with has been marked as read only.
fatal: could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

Why am I getting this error and how do I fix the problem?

答案1

得分: 2

SSH密钥您已添加的是部署密钥,它与存储库关联,并且可以是只读或读写的密钥。通常,大多数SSH密钥与用户关联,并根据该用户的权限访问存储库(可能受限于SSO相关限制)。

然而,部署密钥专门设计为与单个存储库关联,是允许自动化服务与存储库配合工作的良好方式,而无需担心用户失去访问权限后会发生什么。

在您的情况下,您正在使用的部署密钥已标记为只读,因此无法用于推送。如果您打算将此帐户与您的帐户关联而不是与存储库关联,请进入存储库设置中将其删除,然后转到您的帐户设置并在那里添加它。如果您打算将其用作部署密钥,请进入存储库设置,删除密钥,然后重新添加它,并选中“允许写入访问”选项。

请注意,单个密钥只能是单个存储库的只读密钥、读写密钥或用户密钥之一。由于GitHub根据密钥标识访问权限,因此您不能将同一SSH密钥用于多个目的。

英文:

The SSH key you've added is a deploy key, which is a key that's associated with a repository and can be either read-only or read-write. Normally, most SSH keys are associated with a user, and access repositories based on the permissions of that user (possibly with limitations related to SSO).

However, deploy keys are specifically designed to be associated with a single repository, and they're a good way to allow automated services to work with repositories without having to worry about what happens when a user loses access.

In your case, the deploy key you're using has been marked read-only, and so it cannot be used to push. If you had intended this account to be associated with your account instead of the repository, go into the repository settings and remove it, and then go to your account settings and add it there. If you did intend for it to be a deploy key, then go into repository settings, delete the key, and re-add it, checking the "Allow write access" option.

Note that a single key can be only one of a read-only key for a single repo, a read-write key for a single repo, or a user key. Because GitHub identifies access based on the key, you cannot use the same SSH key for multiple purposes.

huangapple
  • 本文由 发表于 2023年4月17日 02:53:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76029749.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定