我可以在VPS上的Linux命令行中成功执行git pull
,但是当我在Node.js中使用execFile执行包含“git pull
”的bash文件时,它给了我一个错误:Command failed: Host key verification failed.
如何解决此问题?
更新:
我收到的整个错误消息是:
{ [Error: Command failed: Host key verification failed. fatal: Could not read
from remote repository. Please make sure you have the correct access rights
and the repository exists. ] killed: false, code: 1, signal: null }
所提供的问题代尔似乎不是同一个问题。
bash文件脚本是这样的,我用它来自动部署我的nodejs应用程序:
git pull && pm2 reload www
我在我的vps上使用ssh协议(protocol)而不是https协议(protocol),以防止每次我从Bitbucket存储库中
git pull
出现密码提示时,都使用它。所以ssh密钥是在我的用户目录~/.ssh/
中生成的。我认为nodejs无法执行bash文件的原因是:在nodejs应用程序中运行bash文件的用户与在命令行中运行bash文件的用户不同。因此,运行nodejs的用户无法使用~/.ssh
中的ssh密钥进行验证。那正确吗?如何解决?
最佳答案
我认为您已正确识别了问题:nodejs应用程序无权访问ssh凭据。您有几种选择:
关于linux - 无法在Node.js中执行git命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24062672/