I wanna execute iptables command on a remote server and print all the iptables command output using php:
$connection = ssh2_connect($server_ip, $server_port);
//authenticating username and password
if(ssh2_auth_password($connection, $server_user, $server_pwd)){
$conn_error=0;
}else{
$conn_error=1;
}
$stream = ssh2_exec($connection, "iptables -L -n --line-number");
stream_set_blocking( $stream, true );
$data = "";
while( $buf = fread($stream,4096) ){
$data .= $buf."<br>";
}
fclose($stream);
server connection and authentication is absolutely fine. but command output is blank, basically its not executing commands except basic commands.