I'm trying to set up personal git account along with my work account. I followed this guide https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/ and my ~/.ssh/config is (some-name is my user name for personal github account)
host github.com
Hostname github.com
User git
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
host some-name.github.com
Hostname github.com
Identityfile ~/.ssh/id_rsa_personal
Run Code Online (Sandbox Code Playgroud)
After this, I ran ssh-add ~/.ssh/id_rsa_personal which was successful.
However, when I do ssh -T some-name.github.com, it fails with
somename@github.com: Permission denied (publickey)
The work account is working fine. I also uploaded newly generated public key on github account.
My git config --list shows user.name=some-name.
update: based on VonC's response, I was able to get ssh -T some-name.github.com to run successfully. However, I am still getting following error when I try to push code into a repo in github account.
ERROR: Permission to some-name/docker-react.git denied to User.
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
I checked the ssh keys uploaded on github, and it is correct.
首先,将用户 git 添加到您的第二个配置中:
host some-name.github.com
Hostname github.com
Identityfile ~/.ssh/id_rsa_personal
User git
Run Code Online (Sandbox Code Playgroud)
然后OP agyeya必须origin相应地修改远程 URL:
git remote set-url origin git@some-name.github.com:some-name/docker-react.git
Run Code Online (Sandbox Code Playgroud)
如果这仍然不起作用(假设公钥已注册到您的 GitHub 帐户):
尝试创建第一个没有关联密码的密钥,以对其进行测试。
这将避免 ssh-agent 需求(同样,用于测试)
请参阅“凭据中私钥的正确格式是什么”,以使用旧的 PEM 格式创建私钥:
ssh-keygen -m PEM -t rsa -P "" -f ~/.ssh/id_rsa_personal
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1786 次 |
| 最近记录: |