I would like to execute commands on remote server via ssh and i use phpseclib. If i run the command, all the output is in one line (because its a string).
I would have the same output as in the local shell
Current var_dump():
string(291) "Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-10 10:08 CEST Nmap scan report for dns.google (8.8.8.8) Host is up (0.0037s latency). Not shown: 998 filtered ports PORT STATE SERVICE 53/tcp open domain 443/tcp open https Nmap done: 1 IP address (1 host up) scanned in 4.59 seconds "
Current Output:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-10 10:14 CEST Nmap scan report for dns.google (8.8.8.8) Host is up (0.0036s latency). Not shown: 998 filtered ports PORT STATE SERVICE 53/tcp open domain 443/tcp open https Nmap done: 1 IP address (1 host up) scanned in 4.50 seconds
Expected Output:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-10 10:14 CEST
Nmap scan report for dns.google (8.8.8.8)
Host is up (0.0037s latency).
Not shown: 998 filtered ports
PORT STATE SERVICE
53/tcp open domain
443/tcp open https
Current Code:
<?php
include 'vendor/autoload.php';
$ssh = new \phpseclib3\Net\SSH2('xxx.xxx.xxx.xxx');
if (!$ssh->login('root', 'password')) {
exit('Login Failed');
}
echo $ssh->exec('nmap 8.8.8.8');
?>
You can use
<pre>