Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有多个帐户的Git在执行ssh时提供相同的用户名_Git_Github_Ssh_Accounts_Multiple Users - Fatal编程技术网

具有多个帐户的Git在执行ssh时提供相同的用户名

具有多个帐户的Git在执行ssh时提供相同的用户名,git,github,ssh,accounts,multiple-users,Git,Github,Ssh,Accounts,Multiple Users,我在mac上有两个git帐户,其中有两组公钥和私钥。我在/.ssh中有一个配置文件来管理这些帐户,如下所示: Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa Host github-user2 HostName github.com User git IdentityFile ~/.ssh/id_rsa_user2 这些帐户中的代码将被推送到2个不同的远程

我在mac上有两个git帐户,其中有两组公钥和私钥。
我在/.ssh中有一个配置文件来管理这些帐户,如下所示:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa

Host github-user2
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_user2
这些帐户中的代码将被推送到2个不同的远程存储库中,我使用以下命令在它们各自的目录中为它们设置了不同的远程存储库:

git remote add origin github.com:xyz_user/abc.git
git remote add origin github-user2:pqr_user/def.git
我成功地从这两个帐户推送这些回购协议。
当我使用ssh时

ssh-add -l
显示添加的两个帐户的私钥。
但是

两者都传达了以下信息:

"Hi user2! You've successfully authenticated, but GitHub does not provide shell access."
还有一件事我注意到了,即使“ssh add-l”中没有列出密钥

在进行ssh连接时,如何区分这两个帐户?
ssh-T从哪里进行身份验证

在进行ssh连接时,如何区分这两个帐户

您不会真的这样做:两个公钥都已在同一个GitHub帐户中注册,因此就GitHub而言,两个ssh都将您验证为“user2”

ssh-T从哪里进行身份验证

它正朝着你的方向看。
这两个公钥都在那里注册,如中所述

在进行ssh连接时,如何区分这两个帐户

您不会真的这样做:两个公钥都已在同一个GitHub帐户中注册,因此就GitHub而言,两个ssh都将您验证为“user2”

ssh-T从哪里进行身份验证

它正朝着你的方向看。

两个公钥都在那里注册,如中所述。

嘿,冯,谢谢你的回复。但是,这两个公钥都在不同的GitHub帐户中注册。@Manu这两个GitHub帐户中有可能存在重复的公钥吗?@Manu另外,请参见此处()两个帐户ssh安装成功的示例。不幸的是,这两个公钥都不同:(@Manu只是想检查一下,你能从另一台计算机上试试你的
ssh-T github.com
,看看是否还提到了“User2”吗?嘿,冯,谢谢你的回复。但是,这两个公钥都在不同的github帐户中注册了。@Manu这两个github帐户中的公钥有可能是重复的吗?@Manu还有,请看这里()一个成功的两个帐户ssh设置的示例。不幸的是,两个公钥都不同:(@Manu只是为了检查,您可以从另一台计算机上尝试您的
ssh-T github.com
,看看是否仍然提到“User2”?
"Hi user2! You've successfully authenticated, but GitHub does not provide shell access."
ssh -T github.com & ssh -T github-user2 provide successful authenticate message.