PHP shell_exec does not work with ssh -
shell_exec works correctly in php, when using ssh not return output..
<?php echo shell_exec("/usr/bin/ssh -i /tmp/key server 'ls'"); ?>
the above command works fine in bash shell , following displays proper output in php
<?php echo shell_exec("ls"); ?>
i hoping done without using third party php library...
using phpseclib, pure php ssh2 implementation:
<?php include('net/ssh2.php'); $ssh = new net_ssh2('www.domain.tld'); $key = new crypt_rsa(); $key->loadkey(file_get_contents('/tmp/key')); if (!$ssh->login('username', $key)) { exit('login failed'); } echo $ssh->exec('ls'); ?>
Comments
Post a Comment