【发布时间】:2014-11-27 02:53:00
【问题描述】:
我有一些代码需要定期从 github 获取代码(在 Windows 机器上)。
当我手动拉取时,我使用 GitBash,并且我已经为我检查的存储库运行了 ssh 密钥,所以一切都很好。但是,当我尝试在 python 子进程中运行相同的操作时,我没有 GitBash 提供的 ssh 服务,并且我无法对 repo 进行身份验证。
我应该如何从这里开始。我可以想到几个不同的选择:
我可以恢复使用 https:// 获取。这是有问题的,因为我正在获取的存储库使用 2 因素身份验证并且将在无人值守的情况下运行。有没有办法从命令行访问具有 2fa 的 https 存储库?
-
我尝试使用将触发 ssh-agent 的参数调用 sh.exe,然后发出我的命令,以便一切都或多或少地以 gitBash 中的方式运行,但这似乎不起作用:
"C:\Program Files (x86)\Git\bin\sh.exe" -c "C:/Program\ Files\ \(x86\)/Git/bin/ssh-agent.exe; C:/Program\ Files\ \(x86\)/Git/bin/ssh.exe -t git@github.com"生产
SSH_AUTH_SOCK=/tmp/ssh-SiVYsy3660/agent.3660; export SSH_AUTH_SOCK; SSH_AGENT_PID=8292; export SSH_AGENT_PID; echo Agent pid 8292; Could not create directory '/.ssh'. The authenticity of host 'github.com (192.30.252.129)' can't be established. RSA key fingerprint is XXXXXXXXXXX Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/.ssh/known_hosts). Permission denied (publickey). 我可以在 python 中使用像
paramiko这样的 ssh 模块来建立连接吗?在我看来,这只是为了 ssh'ing 到远程终端。有没有办法让它提供 git.exe 可以使用的 ssh 连接?
所以,如果有人以前这样做过或有更好的选择,我将不胜感激
【问题讨论】:
标签: python windows git github ssh