I'm trying to run some commands in a remote firewall fortigate using ssh2 on php 7.2. Ssh connection goes ok but my problem is that in fortigate is not possible send many commands in one line, that means it is not possible "'$ command1'. ' && '.' $ command2 '". there is a code that help me to send 3 consecutive commands in order that in the same session execute command 1 then command 2 and lastly command 3?
this is my actually code
<?php
$consulta1 = 'config firewall policy';
$consulta2 = 'edit 32';
$consulta3 = 'set status disable';
$consulta4 = 'end';
$connection = ssh2_connect('192.168.0.100', 22);
ssh2_auth_password($connection, 'user', 'pass');
$ejecucion = "$consulta1 ; $consulta2";
$stream = ssh2_exec($connection, $ejecucion);
stream_set_blocking($stream, true);
$datos = "";
while($buffer = fread($stream, 4096)){
$datos .= $buffer . "<br>";
echo $buffer;
}
fclose($stream);
ssh2_disconnect($connection);
?>
if I send "'$ command1'. ' && '.' $ command2 '" as a ssh command returned syntax error. That is because fortigate doesn't support many commands in one line.