PHP 远程 Sudo 脚本执行
我想要一个 PHP 脚本来使 shell 脚本以 root 身份在远程服务器上执行。该脚本本身需要执行 sudo 命令,因此需要以 root 身份执行。
有什么想法吗?
我尝试让 PHP ssh 登录并使用 sudo 执行,但速度太慢。
(我的两台服务器上都有 Ubuntu 10.04 和 PHP5)
I want a PHP script to cause a shell script to execute on a remote server as root. The script needs to execute sudo commands itself so it needs to be executed as root.
Any Ideas?
I tried having PHP ssh login and execute with sudo but it was too slow.
(I have Ubuntu 10.04 & PHP5 on both servers)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您运行许多单独的命令,否则 SSH 不应太慢。如果速度很慢,则可能是系统负载过高,或者您存在反向 DNS 问题。您可以尝试在
/etc/ssh/sshd_config
中设置UseDNS no
并重新启动 sshd(如果这样可以加快速度) DNS 是问题所在。如果脚本以 root 身份运行则没有意义,它不需要使用 sudo。
SSH shouldn't be to slow unless your running many individual commands. If it is slow either the systems are under high load or you have reverse DNS problems. You could try setting
UseDNS no
in/etc/ssh/sshd_config
and restart sshd if that makes it faster DNS is the problem.Doesn't make sense if the script is running as root it doesn't need to use sudo.
我最近发布了一个项目,允许 PHP 获取真实的 Bash shell 并与之交互。在这里获取它: https://github.com/merlinthemagic/MTS
下载后,您只需使用以下内容代码:
I recently published a project that allows PHP to obtain and interact with a real Bash shell. Get it here: https://github.com/merlinthemagic/MTS
After downloading you would simply use the following code: