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;
    }