权限被拒绝(公钥):使用 Github 的多个存储库和 RSA 密钥

发布于 2024-11-02 15:21:39 字数 1398 浏览 0 评论 0原文

我在创建时收到权限被拒绝(公钥)错误 ssh [电子邮件受保护] 请求。我的感觉是这是因为 它找不到我的 .ssh 文件夹。这是我所拥有的背景 到目前为止已完成:

我之前配置了 github 来工作 与我的存储库:repo1。我跟着 github 网站上的新手指南以及 将我的存储库设置为:

/home/CodeSherpa/repo1/,

其中包含安全内容:

/home/CodeSherpa/.ssh

我配置了 id_rsa 和 id_rsa.pub 根据指南并把 github上我的公开公钥 键。然后我用

ssh [email protected]

进行测试并做了一些推/拉/等命令 一切都很好。

现在,我想添加更多存储库。 我已经移动了本地目录结构 看起来像这样:

/home/CodeSherpa/repos/

*repo1 *repo2 *repo3

我已经在 github 上设置/配置了匹配的存储库。

我是管理员,应该有权访问所有内容。我想给 一名开发人员可以访问 repo1 和repo2 但不是 repo3 和另一个开发人员 访问所有存储库。

我当前的问题是当我尝试初始化新存储库时 在我的本地文件系统上,我不断收到:

“权限被拒绝(公钥)” (使用 ssh [电子邮件受保护]

我的问题是 每个新存储库都必须有本地 RSA 密钥吗? 目前,我的 .ssh 文件夹是我最初为第一个存储库设置的位置:

/home/CodeSherpa/.ssh

我需要这样做吗:

> /home/CodeSherpa/repos/repo1/.ssh/id_rsa
> /home/CodeSherpa/repos/repo2/.ssh/id_rsa
> /home/CodeSherpa/repos/repo3/.ssh/id_rsa

然后为每个存储库设置三个唯一的公钥 在github上?

感谢您的帮助。

I am getting the Permission denied (public key) error when making
an ssh [email protected] request. My feeling is that this is because
it can't find my .ssh folder. Here is the background on what I have
done thus far:

I previously configured github to work
with my a repository : repo1. I followed
the newbie guide on the github site and
set my repo up as:

/home/CodeSherpa/repo1/

with security stuff here:

/home/CodeSherpa/.ssh

I configured id_rsa and id_rsa.pub
according to the guide and put the
public key on github in my public
keys. I then tested with

ssh [email protected]

and did some push/pull/etc commands
and everything worked just fine.

Now, I want to add a few more repositories.
I have moved my local directory structure
around to look like this:

/home/CodeSherpa/repos/

*repo1
*repo2
*repo3

And I have set up / configured the matching repositories on github.

I am the Admin and should have access to everything. I want to give
one developer access to repo1 & repo2 but NOT repo3 and another developer
access to all repos.

MY CURRENT PROBLEM IS that when I try to initialize the new repositories
on my local filesystem I keep getting:

"Permission denied (public key)"
(using ssh [email protected])

MY QUESTION IS do I have to have a local RSA key for each new repository?
Currently, my .ssh folder is where I originally set it up for my first repo:

/home/CodeSherpa/.ssh

Do I need to do this:

> /home/CodeSherpa/repos/repo1/.ssh/id_rsa
> /home/CodeSherpa/repos/repo2/.ssh/id_rsa
> /home/CodeSherpa/repos/repo3/.ssh/id_rsa

And then set up three unique public keys for each repo
on github?

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蘑菇王子 2024-11-09 15:21:39

通常,每个用户只需要一个密钥,而不是每个存储库。我的建议是:

  • 删除计算机中的所有密钥,
  • 删除 github 中的所有密钥,
  • 再次执行此过程,仅一次

但是如果您的目的是每个存储库有一个用户,那么每个用户需要一个 ssh 密钥。为此:

  • 按照 github 中的说明操作 3 次,并为每个密钥指定不同的文件名。
  • 当您想使用这些密钥之一时,请运行 ssh-add [path_to_user_1_key]
    ** 从此时起,您将以 user_1 身份连接到 github
  • 如果您需要以其他用户身份连接,例如 user_2,请运行 ssh-add -Dssd-add [path_to_user_2_key ]

作为示例,我对 github 和 bitbucket 使用相同的 ssh 密钥,并且每台服务器上都有一些存储库。

Usually, you need only one key per user, not per repository. My suggestion would be:

  • delete all the keys in your computer
  • delete all your keys in github
  • follow the process again, just once

BUT If your intention is to have one user per repository, then you'll need one ssh key per user. To do this:

  • follow the instructions in github 3 times, and give each key a different file name.
  • when you want to use one of those keys, run ssh-add [path_to_user_1_key]
    ** from this point, you'll connect to github as user_1
  • If you need to connect as a different user, for example user_2, run ssh-add -D and ssd-add [path_to_user_2_key]

As an example, I use the same ssh key for github and bitbucket, and I have a few repos on each server.

北凤男飞 2024-11-09 15:21:39
  • 在 github 中(实际上在大多数地方),ssh 密钥与用户帐户绑定(因为它用于向 github 验证/验证您确实是您声称的身份),而不是与存储库绑定。
  • 您应该能够将任何其他 github 用户作为协作者添加到您的任何项目中。
  • 添加协作者是控制对 github 上项目的访问的方式。您不需要为此创建多个 ssh 密钥。
  • 您可以通过“存储库管理”-> 为您的项目添加协作者。 “合作者”。
  • In github (in most places really) a ssh key is tied to a user account (because its used to verify/authenticate to github that you are really who you claim to be), not to a repo.
  • You should be able to add any other github user as a collaborator to any of your projects.
  • Adding collaborators is how control access to your projects on github. You don't need to create multipal ssh keys for this.
  • You can add a collaborator to your project by going to "Repository Administration" -> "Collaborators".
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文