我的服务器上有一个laravel应用程序,当发生某些操作时,它运行位于路径/home/user/myFile.sh
上的shell脚本文件,我正在使用Symfony component process,它是错误为Host key verification failed
的响应,当我从服务器使用终端运行时,它运行良好。
我的问题是如何传递此错误以通过我的应用执行文件。
此myFile.sh
:
#!/bin/bash
ssh myuser@xx.xx.xx.xx "bash -s" <<'ENDSSH'
/home/user/another_file.sh $1 $2 $3
laravel应用中的代码:
public function do()
{
$process = new Process(['/home/user/myFile.sh'], null, ['param1', 'param2', 'param3']);
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
return $process->getOutput();
}
another_file.sh
在远程服务器上:
#!/bin/bash
p1= $1;
p2= $2;
p3= $3;
echo "script executed successfully";
答案 0 :(得分:1)
这在AskUbuntu上得到了很好的回答; https://askubuntu.com/a/323629/641754:
如果您在某些远程/脚本化情况下运行,而您对交互式提示添加主机键缺乏交互访问,请按以下方法解决:
$ ssh -o StrictHostKeyChecking=no myuser@xx.xx.xx.xx "bash -s" <<'ENDSSH'