我正在尝试使用 R 中的 system()
函数(在 Windows 7 64 位上)通过公共(public) SSH key 执行 git 命令。当我尝试执行 git 命令时,出现以下错误:
ssh_askpass: exec(rpostback-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我可以在命令提示符下运行完全相同的命令并且它可以工作。我还可以在 git bash shell 上运行完全相同的命令并且它可以工作。我不确定为什么使用 system()
命令从 R 运行时 cmd
找不到 key 。有没有办法指定 system() 命令使用的命令提示符的关键位置?
更新: 一个不起作用的调用示例:
system("git push --set-upstream <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="53343a2713343a273f32317d3e2a343a277d303c3e" rel="noreferrer noopener nofollow">[email protected]</a>:MyGroup/testGitlab.git master")
还有
system("git clone <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e49475a6e49475a424f4c00435749475a004d4143" rel="noreferrer noopener nofollow">[email protected]</a>:MyGroup/gitLabTest.git")
这两个调用都会出现上述相同的错误。
更新 2: 看来,使用 list.files()
从 R 中看不到 ssh key
> list.files("C:/Users/Me/Documents/.ssh/", all.files = TRUE)
[1] "." ".."
我已经验证此目录中有多个 ssh key ,可以使用 ls -a
从 git bash shell 中看到这些 key 。
最佳答案
事实证明,在我的 Windows 系统(7、64 位)上,当使用 git bash shell 创建 SSH key 时,它们被保存到“C:\Users\MyAcount\.ssh”。但是,R
中的 system()
调用的 cmd.exe
正在查找“C:\Users\MyAccount\Documents\.ssh” 。
出于某种原因,当使用直接从操作系统调用的 cmd
提示符时,它会在与 bash shell 相同的 .ssh 目录中查找。去搞清楚。 Windows,我想我永远不会理解你。希望这对那里的人有帮助。
关于r - 在 Windows 中使用 system() 将 git 命令发送到命令提示符时找不到 SSH key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49679874/