PHP shell_exec 使用 ssh 运行 shellscript [英] PHP shell_exec running a shellscript with ssh
问题描述
我有一个 shellscript,它使用 ssh 和一个密钥连接到另一台机器,因此它不需要用户名和密码.
I have a shellscript with connects to a a different machine with ssh and a key so it does not need the username and password.
当我从命令行运行这个脚本时它工作正常..但是当我从 php shell_exec 运行这个脚本时它不起作用.
When i run this script from commandline it works fine.. but when I run this script from php shell_exec it does not work.
如果我与 PHP 建立 ssh 连接并以我自己的用户身份运行脚本,它确实可以工作.
If I make an ssh connection with PHP and run the script as my own user it does work.
现在我的问题:D有没有办法只在 shell_exec
中从 php 运行脚本,而无需以其他用户身份通过 ssh 建立连接?
Now for my question :D
Is there a way to just running the script in shell_exec
from php without making an connection over ssh as a different user?
推荐答案
您是否正确指定了私钥文件?
Did you specify the private key file correctly?
这篇关于PHP shell_exec 使用 ssh 运行 shellscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!