权限被拒绝(公钥):使用 Github 的多个存储库和 RSA 密钥
我在创建时收到权限被拒绝(公钥)错误 ssh [电子邮件受保护] 请求。我的感觉是这是因为 它找不到我的 .ssh 文件夹。这是我所拥有的背景 到目前为止已完成:
我之前配置了 github 来工作 与我的存储库:repo1。我跟着 github 网站上的新手指南以及 将我的存储库设置为:
/home/CodeSherpa/repo1/,
其中包含安全内容:
/home/CodeSherpa/.ssh
我配置了 id_rsa 和 id_rsa.pub 根据指南并把 github上我的公开公钥 键。然后我用
进行测试并做了一些推/拉/等命令 一切都很好。
现在,我想添加更多存储库。 我已经移动了本地目录结构 看起来像这样:
/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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,每个用户只需要一个密钥,而不是每个存储库。我的建议是:
但是如果您的目的是每个存储库有一个用户,那么每个用户需要一个 ssh 密钥。为此:
ssh-add [path_to_user_1_key]
** 从此时起,您将以 user_1 身份连接到 github
ssh-add -D
和ssd-add [path_to_user_2_key ]
作为示例,我对 github 和 bitbucket 使用相同的 ssh 密钥,并且每台服务器上都有一些存储库。
Usually, you need only one key per user, not per repository. My suggestion would be:
BUT If your intention is to have one user per repository, then you'll need one ssh key per user. To do this:
ssh-add [path_to_user_1_key]
** from this point, you'll connect to github as user_1
ssh-add -D
andssd-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.