【发布时间】:2020-06-02 18:47:30
【问题描述】:
我知道有很多这样的问题,但没有答案能够为 redhat 解决这个问题。我有一个 MACOS,有两个帐户,没什么大不了的,但在 Red Hat 上它就不起作用。
我有两个帐号
https://github.com/USER1/REPOSITORY_A.git
https://github.com/USER2/REPOSITORY_B.git
我之前的设置是创建一个用于 USER1 的 SSH 密钥:
~/.ssh/id_rsa.pub
和第二个 USER2 上:
~/.ssh/USER2/id_rsa.pub
添加了 ssh 密钥,例如:
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/USER2/id_rsa
我必须在 github 上为每个密钥添加自己的帐户 SSH 密钥。而且我必须像这样设置我的配置:
vi ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
User git
Host user2-github.com
HostName github.com
AddKeysToAgent yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/user2/id_rsa
User git
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
而且我必须设置 USER2 本地存储库,例如:
git remote set-url origin git@user2-github.com:user2/REPOSITORY_B.git
在 MACOS 上,一切都像魅力一样,但在 redhat 上,当我尝试推送本地 (USER2) 存储库时,它会尝试使用“USER1”凭据...我找不到解决方案,所以我认为我需要你的帮助...
如何在 SSH 和 Red Hat 7 中使用两个不同的 github 帐户?
【问题讨论】:
标签: git ssh redhat multiple-accounts