【发布时间】:2015-05-15 10:07:01
【问题描述】:
GitHub 上的 SSH 配置似乎是一场噩梦。我有多个 GitHub 帐户,但我可以有多个 SSH 密钥。在 GitHub SSH 配置部分,他们提到了这一点:
ssh-keygen -t rsa -C "your_email@example.com" # Creates a new ssh key, using the provided email as a label # Generating public/private rsa key pair.我们强烈建议保持默认设置不变,因此当系统提示您“输入要保存密钥的文件”时,只需按 Enter 即可继续。
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
为什么我应该总是使用id_rsa 文件?它将覆盖我现有的密钥。无论如何,我在这里给一个新名称并生成密钥。我执行将其添加到代理的所有其他步骤,并在 GitHub SSH 密钥部分进行更新。
完成所有这些步骤后,我来到最后一步:
$ ssh -vT git@github.com
Hi animesh11! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3128, received 1976 bytes, in 0.5 seconds
Bytes per second: sent 6077.0, received 3838.9
debug1: Exit status 1
一切都很好,但不知何故git clone 仍然抱怨:
$ git clone git@github.com:regentmarkets/devbox.git
Cloning into 'devbox'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我不知道为什么 ssh -vT 有效而简单克隆无效。
【问题讨论】:
-
您可以为不同的 github 帐户设置多个 ssh 密钥,使用 .git 文件夹下的配置文件负责身份验证。