我有一个脚本试图在后台克隆 Git 存储库,而用户无法提供凭据。因此,它设置GIT_SSH_COMMAND
为启用 OpenSSH 批处理模式。重现问题的示例脚本:
import subprocess, sys
popen = subprocess.Popen(
['git', 'clone', 'https://github.com/NiklasRosenstein/flux.git'],
env={'GIT_SSH_COMMAND': 'ssh -oBatchMode=yes'},
)
popen.wait()
sys.exit(popen.returncode)
没有设置GIT_SSH_COMMAND
,命令运行良好。但有了它,我得到
C:\Users\niklas\Desktop
λ test
Cloning into 'flux'...
Error in GnuTLS initialization: Failed to acquire random data.
fatal: unable to access 'https://github.com/NiklasRosenstein/flux.git/': Couldn't resolve host 'github.com'
这里出了什么问题?使用 Git-for-Windows 2.6.1.windows.1