I am looking to SSH out via PHP. What is the best/most secure way to go about this? I know I can do:
shell_exec("SSH [email protected] mkdir /testing");
Anything better? That feels so 'naughty' :).
I would use phpseclib, a pure PHP SSH implementation. An example:
<?php
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('ls -la');
?>