【发布时间】:2021-03-02 06:16:21
【问题描述】:
我似乎无法从 github 安装私有存储库,而且我很确定我已将问题追溯到密钥文件。复杂的因素是我的 ~/.ssh 目录中有几十个密钥文件,当我尝试指定特定的密钥文件时它似乎不起作用。对于 pip 安装,无论我的语法如何,它都会选择第一个密钥文件。
安装 repo1 有效,包括不存在这样的密钥文件或指定了错误的密钥文件时:
> pip install git+ssh://git@github.com/username/repo1.git
> pip install --cert ~/.ssh/keyfile1 git+ssh://git@github.com/username/repo1.git
> pip install --cert ~/.ssh/keyfile1_BLAH_NO_SUCH_FILE git+ssh://git@github.com/username/repo1.git
> pip install --client-cert ~/.ssh/keyfile1 git+ssh://git@github.com/username/repo1.git
> pip install --client-cert ~/.ssh/keyfile1_BLAH_NO_SUCH_FILE git+ssh://git@github.com/username/repo1.git
> pip install --client-cert ~/.ssh/keyfile2 git+ssh://git@github.com/username/repo1.git
无论语法如何,安装 repo2 都不起作用:
> pip install git+ssh://git@github.com/username/repo2.git
> pip install --cert ~/.ssh/keyfile2 git+ssh://git@github.com/username/repo2.git
> pip install --client-cert ~/.ssh/keyfile2 git+ssh://git@github.com/username/repo2.git
我可以通过这样做来验证密钥文件是否正确并被 Github 识别:
> ssh -T git@github.com
Hi username/repo1! You've successfully authenticated, but GitHub does not provide shell access.
> ssh -T git@github.com -i ~/.ssh/keyfile1
Hi username/repo1! You've successfully authenticated, but GitHub does not provide shell access.
> ssh -T git@github.com -i ~/.ssh/keyfile2
Hi username/repo2! You've successfully authenticated, but GitHub does not provide shell access.
如果密钥文件未指定或指定不正确,我可以验证是否使用了 keyfile1:
> ssh -T git@github.com -i ~/.ssh/keyfile1_BLAH_NO_SUCH_FILE
Warning: Identity file keyfile1_BLAH_NO_SUCH_FILE not accessible: No such file or directory.
Hi username/repo1! You've successfully authenticated, but GitHub does not provide shell access.
> ssh -T git@github.com
Hi username/repo1! You've successfully authenticated, but GitHub does not provide shell access.
所以我认为这告诉我 keyfile2 很好。
为了消除 repo2 出现问题的可能性,我将 keyfile1 移到了 github 中的 repo2,然后 repo2 是我可以 pip 安装的唯一存储库。
因此,我的 pip install 语法似乎只适用于第一个密钥文件,因为它首先找到它,我要么错误地指定了密钥文件,要么我的规范被忽略了。
点 20.2.4
有什么想法吗?
【问题讨论】:
标签: git github ssh pip ssh-keys