【发布时间】:2021-04-08 13:48:20
【问题描述】:
我在同一台计算机上有 2 个 github 帐户,我希望能够提供我希望进行身份验证的用户(即 ssh userA@github 或 ssh userB@github)。这适用于以下 .ssh/config 文件:
Host github.com
Hostname github.com
PreferredAuthentications publickey
IdentityFile .ssh\userA_key
User userA
Host github.com
Hostname github.com
PreferredAuthentications publickey
IdentityFile .ssh\userB_key
User userB
但是,如果我使用 git 用户(即ssh git@github.com)进行身份验证。我收到一条成功通过身份验证的消息,其中包含首先出现在配置文件 (userA) 中的用户。有没有办法防止这种情况?我想提供 userA 或 userB,但无法以 git 用户身份进行身份验证。
【问题讨论】:
-
您只能以
git@github.com身份进行身份验证。您是通过您提供的 ssh 密钥而非用户名来识别的。