0

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)

1

2 Answers 2

2

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.

The script needs to execute sudo commands itself so it needs to be executed as root.

Doesn't make sense if the script is running as root it doesn't need to use sudo.

Sign up to request clarification or add additional context in comments.

Comments

0

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:

$shell    = \MTS\Factories::getDevices()->getLocalHost()->getShell('bash', true);
$return1  = $shell->exeCmd('yourFirstCommand');
$return2  = $shell->exeCmd('yourSecondCommand');
//the return will be a string containing the return of the script
echo $return1;
echo $return2;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.