if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); if(!($con = ssh2_connect("oracle", 22))){ echo "No puedo establecer una conexion SSH\n"; } else { if (ssh2_auth_pubkey_file($con, 'root', '/home/usuario/.ssh/id_rsa.pub', '/home/usuario/.ssh/id_rsa', 'secret')) { // echo "Public Key Authentication Successful\n"; } else { die('Public Key Authentication Failed'); } if (!($stream = ssh2_exec($con, "/home/usuario/dokuwiki_archlogs.pl" ))) { echo "fail: unable to execute command\n"; } else { // collect returning data from command stream_set_blocking($stream, true); $data = ""; while ($buf = fread($stream,4096)) { $data .= $buf; } fclose($stream); print $data; } }