I\'m trying to execute a simple shell command and print the result on a web page but the results are empty. Below is one bit of code I found but nothing has worked thus far.
Using a more object oriented solution, you can install phpseclib version 2 with:
composer require phpseclib/phpseclib
And then just create your ssh object:
$ssh = new SSH2('yourhost');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
In this exemple i have used a connection through username and password but you can also connect via ssh-keys. If the connection is successful you can execute the method exec to execute you command on the server.