I have a linux server and want to execute a script in "sudo -iu rood_user" using PHP with phpseclib library. When I run the below command, it successfully run the normal_user.sh script, but cannot run root_user script.
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
echo $ssh->exec('pwd');
echo $ssh->exec('./normal_user.sh');
Now I want to execute a script which is accessible by root user. In linux I used below command to execute the script
user# sudo -iu user
password:"password"
root_user# ./root_user.sh
I want to excute the script which is accessible by "sudo -iu user" with password in phpseclib. It will be helpful if any one can told me how to run that script saved in root_user