我有一个脚本,尝试在后台克隆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版本。