我正在尝试配置一台远程 linux 机器来访问我拥有的两个不同的 git 帐户。我不断获得身份验证访问权限。
> git push
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我采取的步骤,
key1和key2)~/.ssh/config 1 # Default github account: key1
2 Host github.com
3 HostName github.com
4 IdentityFile ~/.ssh/key1
5 IdentitiesOnly yes
6
7 # Other github account: key2
8 Host github-key2
9 HostName github.com
10 IdentityFile ~/.ssh/key2
11 IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
.pub版本添加到我的用户帐户下的两个 git 帐户中settings/ssh keys。ssh-add ~/.ssh/key1我不确定从这里去哪里以及下一步是什么,为什么这不起作用。我觉得我可能遗漏了一步。
TL;博士:将以下条目添加到您的~/.ssh/config地方$user是GitHub的用户名和$key是在设置为GitHub的用户为该用户指定和定义的私有密钥:
Host github.com-$user
Hostname github.com
User git
IdentityFile ~/.ssh/$key
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
然后,配置您的 git 远程 URL:
git remote add origin git@github.com-$user:$user/$repo
Run Code Online (Sandbox Code Playgroud)
基本上,我有一个用于工作/个人项目的长期运行的 SSH 密钥,然后想为不相关的副项目添加一个新密钥。我执行了您在问题中概述的所有步骤,但仍然出现相同的错误。正在做$ GIT_SSH_COMMAND='ssh -v' git fetch表明 git 首先传递了我的主要用户的私钥,即使它作为有效密钥正确地进行了身份验证,该用户当然对新用户的私有存储库没有权限。
这篇文章是相关的:https : //medium.com/@ordinary.yobi/multiple-ssh-keys-on-github-f75a372d5374
这是我的第一个答案,希望对您有所帮助。我刚刚解决了这个确切的问题,这非常令人沮丧。
编辑:哎呀,忘记了关键部分。对不起!
| 归档时间: |
|
| 查看次数: |
47 次 |
| 最近记录: |