public function exec($cmd)
    {
        
        if ($this->jumphost) {
            $cmd = "ssh " . $this->jumphost . " " . $cmd;
        }
        
        if ( ! ($stream = ssh2_exec($this->connection, $cmd))) {
            throw new \Exception('SSH command failed');
        }
        stream_set_blocking($stream, true);
        $data = "";
        while ($buf = fread($stream, 4096)) {
            $data .= $buf;
        }
        fclose($stream);
        
        return $data;
    }
public function exec($cmd)
    {
        
        if ($this->jumphost) {
            $cmd = "ssh " . $this->jumphost . " " . $cmd;
        }
        
        if ( ! ($stream = ssh2_exec($this->connection, $cmd))) {
            throw new \Exception('SSH command failed');
        }
        stream_set_blocking($stream, true);
        $data = "";
        while ($buf = fread($stream, 4096)) {
            $data .= $buf;
        }
        fclose($stream);
        
        return $data;
    }
public function exec ( $ cmd ) { if ( $ this -> jumphost ) { $ cmd = "ssh " . $ this -> jumphost . " " . $ cmd ; } if ( ! ( $ stream = ssh2_exec ( $ this -> connection , $ cmd ) ) ) { throw new \ Exception ( 'SSH command failed' ) ; } stream_set_blocking ( $ stream , true ) ; $ data = "" ; while ( $ buf = fread ( $ stream , 4096 ) ) { $ data .= $ buf ; } fclose ( $ stream ) ; return $ data ; }
Execute a command on the server, or pass it trough the jump server

@param $cmd

@return string
@throws \Exception
Execute a command on the server or pass it trough the jump server