Mac*_*ser 11 python git ssh bash pip
有谁知道是否有一种简单的方法可以发现在何处pip install git+ssh:///...
搜索 ssh 密钥?
我在 Windows 10 上。我需要在 conda 虚拟环境中使用 pip 从 github 安装一个私有远程存储库。我是回购所有者。我通过 github.com 设置了一个公共/私有 ssh 密钥对。我的本地密钥存储在C:\Users\MyName\\.ssh\id_rsa
. 使用此密钥,我可以使用我的 IDE Eclipse 从 github 毫无问题地推拉。
但是,当我使用激活的 conda 环境执行以下命令时:
pip install git+ssh://github.com/USER_NAME/REPO_NAME.git
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Collecting git+ssh://github.com/USER_NAME/REPO_NAME.git
Cloning ssh://github.com/USER_NAME/REPO_NAME.git to
c:\users\USER_NAME\appdata\local\temp\pip-ghf3ts-build
Warning: Permanently added 'github.com,IP_ADDRESS' (RSA) to the list of
known hosts.
Permission denied (publickey).
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)
我知道 repo 存在,我知道 ssh 密钥工作正常;所以,我假设 pip 调用的任何 ssh 例程都没有正确配置。
从那时起我已经解决了这个问题,并且“错误配置”假设被证明是正确的!我向 C:\Users\MyName\.ssh 添加了一个配置文件,指定要使用的文件。Wham-bam,它现在很好用。
然而!我仍然有兴趣知道是否已经确认 pip 在该目录中查找 ssh 密钥和配置;所以,我暂时将这个问题保持开放。
Nik*_*nyh 11
要在具有多个 ssh 密钥的项目中进行部署,请执行以下操作:
$ export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key_1"
$ pip install git+ssh://git@<my_hosted_gitlab>/project_with_deploy_key_1
$ export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key_2"
$ pip install git+ssh://git@<my_hosted_gitlab>/project_with_deploy_key_2
Run Code Online (Sandbox Code Playgroud)
它可以集成到 CI 过程中。
msm*_*ens 10
在GIT_SSH_COMMAND
环境变量使覆盖了Git使用运行SSH命令。在这种情况下,您希望启用详细输出。在 Windows 上,这看起来像:
set GIT_SSH_COMMAND=ssh -v
Run Code Online (Sandbox Code Playgroud)
然后,当您运行 时pip install git+ssh://github.com/USER_NAME/REPO_NAME.git
,ssh 会输出调试信息,包括查找密钥的位置:
set GIT_SSH_COMMAND=ssh -v
Run Code Online (Sandbox Code Playgroud)