shell_exec中的PHP sudo [英] PHP sudo in shell_exec
本文介绍了shell_exec中的PHP sudo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用shell_exec以root身份执行命令.现在我知道这很危险,但是请相信我,您需要使用MOD_AUTH登录并具有正确的权限才能进入此页面.是安全的.我该怎么办呢?
I want to execute a command as root with shell_exec. Now I know this is dangerous, but believe me, you need to login with MOD_AUTH and have the right privilleges to come to this page. It's secure. How can I get this done?
推荐答案
您可以使用 phpseclib的最新SVN版本纯PHP SSH实现.例如.
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
$ssh->login('username', 'password');
$ssh->read('[prompt]');
$ssh->write("sudo command\n");
$ssh->read('Password:');
$ssh->write("Password\n");
echo $ssh->read('[prompt]');
?>
这篇关于shell_exec中的PHP sudo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文