【发布时间】:2020-02-18 03:46:59
【问题描述】:
我有两个不同的帐户,我必须将更改上传到,这里的问题是 GitHub 帐户和 Bitbucket 帐户有不同的电子邮件地址,所以我正在尝试配置多个 ssh 密钥以继续提交、推送并分别从 Github 和 Bitbucket 拉取更改。
我尝试通过运行生成两个不同的 ssh 密钥:
ssh-keygen -t rsa -C "My.CorporateAddress@company.com"
然后,当被要求输入保存密钥的文件时,我添加以下内容:
Enter file in which to save the key (/Users/myUser/.ssh/id_rsa): /Users/myUser/.ssh/id_rsa_github
我对 bitbucket 执行相同的步骤。
然后我生成一个名为 config 的文件并通过添加来编辑它:
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github
Host bitbucket
HostName corporate-address.com
User git
IdentityFile ~/.ssh/id_rsa_bitbucket
但是当我跑步时:
ssh -T git@bitbucket
或者:
ssh -T git@github
并尝试对其中任何一个提出拉取请求,我收到以下错误:
GITHUB ERROR:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
---------------------------------------------------
---------------------------------------------------
BITBUCKET ERROR:
git@bitbucket.corporate.companyName.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
出于安全原因,我省略了公司名称。
我想要实现的是可以同时使用我的工作 Bitbucket 帐户和我的个人 Github 帐户,它们配置了不同的电子邮件地址。
我做错了什么?您的反馈将不胜感激!
【问题讨论】:
标签: macos github ssh bitbucket ssh-keys