Пример #1
5
function sshiconn($cmd, $pass, $ip, $sshp = 22)
{
    $ip = $_REQUEST['ip'];
    $pass = $_REQUEST['pass'];
    $sshp = $_REQUEST['sshp'];
    if (!isset($_REQUEST['sshp'])) {
        $sshp = '22';
    }
    $connection = ssh2_connect($ip, $sshp);
    if (!$connection) {
        throw new Exception("fail: unable to establish connection\nPlease IP or if server is on and connected");
    }
    $pass_success = ssh2_auth_password($connection, 'root', $pass);
    if (!$pass_success) {
        throw new Exception("fail: unable to establish connection\nPlease Check your password");
    }
    $stream = ssh2_exec($connection, $cmd);
    $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
    stream_set_blocking($errorStream, true);
    stream_set_blocking($stream, true);
    print_r($cmd);
    $output = stream_get_contents($stream);
    fclose($stream);
    fclose($errorStream);
    ssh2_exec($connection, 'exit');
    unset($connection);
    return $output;
}
Пример #2
2
 /**
  *
  */
 public function connect()
 {
     $this->ssh = ssh2_connect($this->configuration['hostname'], $this->configuration['port']);
     $username = $this->configuration['username'];
     switch ($this->configuration[SftpDriver::CONFIG_AUTHENTICATION_METHOD]) {
         case static::AUTHENTICATION_PASSWORD:
             ssh2_auth_password($this->ssh, $username, $this->configuration['password']);
             break;
         case static::AUTHENTICATION_PUBKEY:
             $publicKey = $this->configuration['publicKey'];
             $privateKey = $this->configuration['privateKey'];
             if (!file_exists($publicKey) || !file_exists($privateKey)) {
                 return;
             }
             $password = $this->configuration['privateKeyPassword'];
             if (empty($password)) {
                 $password = null;
             }
             ssh2_auth_pubkey_file($this->ssh, $username, $publicKey, $privateKey, $password);
             break;
         default:
     }
     $this->sftp = ssh2_sftp($this->ssh);
     $this->sftpWrapper = 'ssh2.sftp://' . $this->sftp;
     $this->sftpWrapperLength = strlen($this->sftpWrapper);
     $this->iteratorFlags = \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::FOLLOW_SYMLINKS;
     return true;
 }
 public function Authenticate($uid, $pass)
 {
     $this->AuthResult = false;
     // Connect
     $con = ssh2_connect($this->RemoteHost, $this->RemotePort);
     if ($con === false) {
         return ulLoginBackend::ERROR;
     }
     // Check fingerprint
     if ($this->RemoteFingerprint != '') {
         if (ssh2_fingerprint($con, SSH2_FINGERPRINT_SHA1 | SSH2_FINGERPRINT_HEX) != $this->RemoteFingerprint) {
             return ulLoginBackend::ERROR;
         }
     }
     // Test if server supports password-based authentication
     $auth_methods = ssh2_auth_none($con, 'user');
     if (!in_array('password', $auth_methods)) {
         return ulLoginBackend::ERROR;
     }
     // Connect again, because we can only try to authenticate once on a connection
     $con = ssh2_connect($this->RemoteHost, $this->RemotePort);
     if ($con === false) {
         return ulLoginBackend::ERROR;
     }
     // Try to authenticate
     if (ssh2_auth_password($con, $uid, $pass)) {
         $this->AuthResult = $uid;
         return true;
     } else {
         return ulLoginBackend::BAD_CREDENTIALS;
     }
 }
Пример #4
0
 function _connectandexecute($hostname, $port, $fingerprint, $user, $pass, $command)
 {
     // connect via ssh2
     $ssh = ssh2_connect($hostname, $port);
     if (!$ssh) {
         die("connection failed!");
     }
     $theirfingerprint = ssh2_fingerprint($ssh, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
     if (strtoupper($theirfingerprint) != strtoupper($fingerprint)) {
         die("fingerprint mismatch!");
     }
     if (!ssh2_auth_password($ssh, $user, $pass)) {
         die("authentication failed!");
     }
     // shell, as Brocade really doesn't seem to like exec
     if (!($sock = ssh2_shell($ssh, 'vt102', null, 80, 40, SSH2_TERM_UNIT_CHARS))) {
         die("failed to establish shell!\n");
     }
     fwrite($sock, "terminal length 0" . PHP_EOL);
     fwrite($sock, $command . PHP_EOL);
     sleep(1);
     // seems to be a magic trick...
     stream_set_blocking($sock, true);
     $data = "";
     while ($buf = fread($sock, 4096)) {
         flush();
         if (preg_match('/SSH@.+#$/', $buf)) {
             break;
         }
         $data .= $buf;
     }
     fclose($sock);
     return $data;
 }
Пример #5
0
 public function handle()
 {
     /**
      * Estamblish SSH connection,
      * put site under maintenance,
      * pull chamges from git,
      * install composer dependencies,
      * execute migrations,
      * put site online
      */
     $remote = config('pckg.framework.' . DeployProject::class . '.remotes.default');
     $path = $remote['root'];
     $commands = ['cd ' . $path => 'Changing root directory', 'php ' . $path . 'console project:down' => 'Putting project offline', 'php ' . $path . 'console project:pull' => 'Executing project:pull', 'php ' . $path . 'console migrator:install' => 'Installing migrations', 'php ' . $path . 'console project:up' => 'Putting project up', 'php ' . $path . 'console cache:clear' => 'Clearing cache'];
     $this->output('Estamblishing SSH connection.');
     $sshConnection = ssh2_connect($remote['host'], $remote['port']);
     $this->output('SSH connection estamblished.');
     /**
      * Authenticate.
      */
     if (!ssh2_auth_password($sshConnection, $remote['username'], $remote['password'])) {
         throw new Exception('Cannot estamblish SSH connection to remote');
     }
     foreach ($commands as $command => $notice) {
         $this->output($notice);
         $stream = ssh2_exec($sshConnection, $command);
         $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
         stream_set_blocking($errorStream, true);
         stream_set_blocking($stream, true);
         $errorStreamContent = stream_get_contents($errorStream);
         $streamContent = stream_get_contents($stream);
         $this->output($errorStreamContent . "\n" . $streamContent);
     }
     $this->output('Done!');
 }
Пример #6
0
 public function connect()
 {
     $methods = array();
     if ($this->use_pubkey_file_) {
         $methods['hostkey'] = 'ssh-rsa';
     }
     $conn = ssh2_connect($this->conf_['host'], $this->conf_['port'], $methods);
     if (false === $conn) {
         $this->setErr_(-1, sprintf('failed to connect [%s:%d]', $this->conf_['host'], $this->conf_['port']));
         return false;
     }
     if ($this->use_pubkey_file_) {
         $rc = ssh2_auth_pubkey_file($conn, $this->conf_['user'], $this->conf_['pubkey_file'], $this->conf_['privkey_file'], isset($this->conf_['passphrase']) ? $this->conf_['passphrase'] : NULL);
         if (false === $rc) {
             $this->setErr_(-1, sprintf('failed to auth with[%s:%s,%s,%s]', $this->conf_['user'], $this->conf_['pubkey_file'], $this->conf_['privkey_file'], $this->conf_['passphrase']));
             return false;
         }
     } else {
         $rc = ssh2_auth_password($conn, $this->conf_['user'], $this->conf_['passwd']);
         if (false === $rc) {
             $this->setErr_(-1, sprintf('failed to auth with[%s:%s]', $this->conf_['user'], $this->conf_['passwd']));
             return false;
         }
     }
     $this->conn_ = $conn;
     return true;
 }
Пример #7
0
 public function authenticate($resource)
 {
     if (!is_resource($resource)) {
         throw new \Exception("Invalid SSH resource!");
     }
     return ssh2_auth_password($resource, $this->username, $this->password);
 }
Пример #8
0
 function getSFTPList()
 {
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     $connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
     if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $sftp = ssh2_sftp($connection);
     $curpwd = "ssh2.sftp://{$sftp}" . $this->pwd;
     $dh = @opendir($curpwd);
     if (!$dh) {
         return new Object(-1, 'msg_ftp_invalid_path');
     }
     $list = array();
     while (($file = readdir($dh)) !== false) {
         if (!is_dir($curpwd . $file)) {
             continue;
         }
         $list[] = $file . "/";
     }
     closedir($dh);
     $this->add('list', $list);
 }
Пример #9
0
 function coneccionSshImg($ids, $mBanner, $config)
 {
     $porciones = explode(",", $ids);
     foreach ($porciones as $value) {
         $dataBanner = $mBanner->select($value);
         $avanzado = ROOT_IMG_DINAMIC . '/banner/avanzado/' . $dataBanner["ImgAvanzado"];
         $basico128 = ROOT_IMG_DINAMIC . '/banner/basico128/' . $dataBanner["ImgBasico128"];
         $basico240 = ROOT_IMG_DINAMIC . '/banner/basico240/' . $dataBanner["ImgBasico240"];
         $basico360 = ROOT_IMG_DINAMIC . '/banner/basico360/' . $dataBanner["ImgBasico360"];
         if (!function_exists("ssh2_connect")) {
             die("function ssh2_connect doesn't exist");
         }
         if (!($con = ssh2_connect($config['app']['server'], $config['app']['puerto']))) {
             echo "fail: unable to establish connection\n";
         } else {
             if (!ssh2_auth_password($con, $config['app']['user'], $config['app']['pass'])) {
                 echo "fail: unable to authenticate\n";
             } else {
                 ssh2_scp_send($con, $avanzado, $config['app']['rutaImg'] . 'banner/avanzado/' . $dataBanner["ImgAvanzado"], 0644);
                 ssh2_scp_send($con, $basico128, $config['app']['rutaImg'] . 'banner/basico128/' . $dataBanner["ImgBasico128"], 0644);
                 ssh2_scp_send($con, $basico240, $config['app']['rutaImg'] . 'banner/basico240/' . $dataBanner["ImgBasico240"], 0644);
                 ssh2_scp_send($con, $basico360, $config['app']['rutaImg'] . 'banner/basico360/' . $dataBanner["ImgBasico360"], 0644);
             }
             ssh2_exec($con, 'exit');
         }
     }
     return;
 }
Пример #10
0
 function __construct($cfg)
 {
     // set default options if missing
     static $defaults = array('port' => 22, 'user' => 'root');
     if (is_object($cfg)) {
         $cfg = json_decode(json_encode($cfg), 1);
     }
     foreach ($defaults as $k => $v) {
         if (!isset($cfg[$k])) {
             $cfg[$k] = $v;
         }
     }
     // connect ssh2
     $this->ssh2 = ssh2_connect($cfg['host'], $cfg['port']);
     if (!$this->ssh2) {
         throw new \Exception("can't connect trough ssh2\n");
     }
     // authorize
     if (isset($cfg['key'])) {
         // private/public key authentication requested
         if (!ssh2_auth_pubkey_file($this->ssh2, $cfg['user'], $cfg['key']['pub'], $cfg['key']['pvt'], isset($cfg['key']['pass']) ? $cfg['key']['pass'] : NULL)) {
             throw new \Exception("can't authorize via key");
         }
     } elseif (isset($cfg['pass'])) {
         // username & password authentication
         if (!ssh2_auth_password($this->ssh2, $cfg['user'], $cfg['pass'])) {
             throw new \Exception("can't authorize via user & pass");
         }
     } else {
         throw new \Exception("not enough authentication information provided");
     }
     $this->sftp = ssh2_sftp($this->ssh2);
 }
Пример #11
0
function get_list($myhost, $usern, $passw, $mypath, &$data)
{
    if (!function_exists("ssh2_connect")) {
        die("function ssh2_connect doesn't exist");
    }
    if (!($conn = ssh2_connect($myhost, 22))) {
        echo "fail: unable to establish connection\n";
    } else {
        if (!ssh2_auth_password($conn, $usern, $passw)) {
            echo "fail: unable to authenticate\n";
        } else {
            if (!($stream = ssh2_exec($conn, "ls -1 " . $mypath))) {
                echo "fail: unable to execute command\n";
            } else {
                stream_set_blocking($stream, true);
                // allow command to finish
                $data = "";
                while ($buf = fread($stream, 4096)) {
                    $data .= $buf;
                }
                fclose($stream);
            }
        }
    }
    ssh2_exec($conn, 'exit');
}
Пример #12
0
 function password($username, $password)
 {
     if ($this->ssh && is_resource($this->ssh)) {
         $this->auth = new AuthenticatedDetails(__FUNCTION__, array($username, $password));
         return ssh2_auth_password($this->ssh, $username, $password);
     }
 }
Пример #13
0
 /**
  * @param Client $client
  * @throws \RuntimeException
  *
  * @return mixed
  */
 public function authenticate(Client $client)
 {
     if (!@ssh2_auth_password($client->getConnection(), $this->getUser(), $this->getPassword())) {
         throw new \RuntimeException('Authentication Failed');
     }
     parent::authenticate($client);
 }
Пример #14
0
 /**
  * @param resource $resource
  * @throws \Exception
  */
 public function authenticate($resource)
 {
     if (!@ssh2_auth_password($resource, $this->username, $this->password)) {
         // @ prevent warning, on invalid authentication throws exception
         throw new \Exception("Authentication failed for user '{$this->username}' using public key: Username/Password combination invalid");
     }
 }
Пример #15
0
 public function authPassword($user, $password, $skiperror = false)
 {
     $this->user = $user;
     $this->password = $password;
     if ($this->lib == 'phpext') {
         try {
             $auth = @ssh2_auth_password($this->con, $this->user, $this->password);
         } catch (Exception $e) {
         }
         if (!$auth) {
             if ($skiperror) {
                 return false;
             }
             die("Authorization failed !");
         }
     } else {
         if (!$this->con->login($this->user, $this->password)) {
             if ($skiperror) {
                 return false;
             }
             die("Authorization failed !");
         }
     }
     return true;
 }
Пример #16
0
 public function ssh()
 {
     if (!function_exists("ssh2_connect")) {
         die("function ssh2_connect doesn't exist");
     }
     // log in at server1.example.com on port 22
     if (!($con = ssh2_connect("nao.local", 22))) {
         echo "fail: unable to establish connection\n";
     } else {
         //try to authenticate with username root, password secretpassword
         if (!ssh2_auth_password($con, "nao", "nao")) {
             echo "fail: unable to authenticate\n";
         } else {
             // allright, we're in!
             echo "okay: logged in...\n";
             // execute a command
             if (!($stream = ssh2_exec($con, "ls -al"))) {
                 echo "fail: unable to execute command\n";
             } else {
                 // collect returning data from command
                 stream_set_blocking($stream, true);
                 $data = "";
                 while ($buf = fread($stream, 4096)) {
                     $data .= $buf;
                 }
                 fclose($stream);
             }
         }
     }
 }
Пример #17
0
 public function __construct($config)
 {
     foreach ($config as $name => $value) {
         $this->{$name} = $value;
     }
     $methods = array();
     if (!isset($this->auth['method'])) {
         error('Unspecified authentication method.');
     }
     // Connect
     $this->connection = ssh2_connect($this->host, isset($this->port) ? $this->port : 22, $methods);
     switch ($this->auth['method']) {
         case 'pubkey':
             if (!isset($this->auth['public'])) {
                 error('Public key filename not specified.');
             }
             if (!isset($this->auth['private'])) {
                 error('Private key filename not specified.');
             }
             if (!ssh2_auth_pubkey_file($this->connection, $this->auth['username'], $this->auth['public'], $this->auth['private'], isset($this->auth['passphrase']) ? $this->auth['passphrase'] : null)) {
                 error('Public key authentication failed.');
             }
             break;
         case 'plain':
             if (!ssh2_auth_password($this->connection, $this->auth['username'], $this->auth['password'])) {
                 error('Plain-text authentication failed.');
             }
             break;
         default:
             error('Unknown authentication method: "' . $this->auth['method'] . '".');
     }
 }
Пример #18
0
 /**
  * Connect operation
  */
 public function connect()
 {
     if ($this->_ssh2 != null) {
         // Already connected
         return;
     }
     // Connect to server
     $host = isset($this->_config['hostname']) ? $this->_config['hostname'] : 'localhost';
     $port = isset($this->_config['port']) ? $this->_config['port'] : 22;
     $username = isset($this->_config['username']) ? $this->_config['username'] : '';
     $password = isset($this->_config['password']) ? $this->_config['password'] : null;
     $this->_ssh2 = ssh2_connect($host, $port);
     if ($this->_ssh2 === FALSE) {
         throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_open_connection'), array(':host' => $host, 'port' => $port));
     }
     // Check fingerprint if it is specified
     if (isset($this->_config['fingerprint'])) {
         if (strtolower(ssh2_fingerprint($this->_ssh2)) != strtolower($this->_config['fingerprint'])) {
             throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_fingerprint_validation'), array(':key' => ssh2_fingerprint($this->_ssh2)));
         }
     }
     // Connect with certificate if it is specified
     if (isset($this->_config['pubkeyfile']) and isset($this->_config['privkeyfile'])) {
         if (!@ssh2_auth_pubkey_file($this->_ssh2, $username, $this->_config['pubkeyfile'], $this->_config['privkeyfile'], $password)) {
             throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_authentication'));
         }
     } else {
         if (!@ssh2_auth_password($this->_ssh2, $username, $password)) {
             throw new Kohana_Transfer_Exception(Kohana::message('transfer', 'fail_authentication'));
         }
     }
     // Enable SFTP mode
     $this->_sftp = ssh2_sftp($this->_ssh2);
 }
Пример #19
0
 /**
  * @param resource $connection
  * @param Config $config
  * @return resource
  * @throws ConnectionFailed
  */
 private function authenticateConnection($connection, Config $config)
 {
     $auth = @ssh2_auth_password($connection, $config->getUserName(), $config->getPassWord());
     if (!$auth) {
         throw new ConnectionFailed('Authentication with ZyXEL failed');
     }
     return $connection;
 }
Пример #20
0
 public function authPassword($user, $password)
 {
     if (!ssh2_auth_password($this->connection, $user, $password)) {
         $this->logs[] = "Password Authorization failed";
         return false;
     }
     return true;
 }
Пример #21
0
 /**
  * @inheritdoc
  */
 public function connect()
 {
     $this->setFtp(ssh2_connect($this->getFtpHost(), $this->getFtpPort()));
     $result = ssh2_auth_password($this->getFtp(), $this->getFtpUser(), $this->getFtpPassword());
     if (false === $result) {
         throw new \Exception("Can't log in to " . $this->getFtpHost());
     }
 }
Пример #22
0
 public function connect()
 {
     if (!($this->connection = ssh2_connect($this->ssh_host, $this->ssh_port))) {
         throw new Exception('Cannot connect to server');
     }
     if (!ssh2_auth_password($this->connection, $this->ssh_auth_user, $this->ssh_auth_pass)) {
         throw new Exception('Autentication rejected by server');
     }
 }
Пример #23
0
 public function authenticate()
 {
     $this->logAction("Authenticating to {$this->host}");
     if (ssh2_auth_password($this->conn, $this->user, $this->pass)) {
         return $this;
     }
     $this->logAction("Authentication to {$this->host} failed");
     throw new Exception("Unable to authenticate to {$this->host}");
 }
Пример #24
0
 public function connect($hostname, $username, $password)
 {
     if ($link = ssh2_connect($hostname, 22)) {
         if (ssh2_auth_password($link, $username, $password)) {
             return $link;
         }
     }
     exit("Ошибка: Не удалось соединиться с сервером!");
 }
Пример #25
0
 static function execute1($user, $mdp, $cmd)
 {
     $connection = \ssh2_connect('localhost', 22);
     \ssh2_auth_password($connection, $user, $mdp);
     $table = array();
     $shell = ssh2_shell($connection, 'xterm');
     fwrite($shell, $cmd . PHP_EOL);
     sleep(10);
     return $table;
 }
Пример #26
0
 /**
  * Implements Drupal\Core\FileTransfer\FileTransfer::connect().
  */
 public function connect()
 {
     $this->connection = @ssh2_connect($this->hostname, $this->port);
     if (!$this->connection) {
         throw new FileTransferException('SSH Connection failed to @host:@port', NULL, array('@host' => $this->hostname, '@port' => $this->port));
     }
     if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) {
         throw new FileTransferException('The supplied username/password combination was not accepted.');
     }
 }
Пример #27
0
 public function killSc_Trans($sc_rel_id)
 {
     $PID = \DB::queryFirstRow("SELECT sc_trans_pid FROM sc_rel WHERE id=%s", $sc_rel_id);
     $SSHConf = $this->getSSHConf();
     $connection = ssh2_connect($SSHConf['ip'], $SSHConf['port']);
     ssh2_auth_password($connection, $SSHConf['user'], $SSHConf['pass']);
     ssh2_exec($connection, 'kill ' . $PID['sc_trans_pid']);
     sleep(1);
     $this->setPID($sc_rel_id, '0');
 }
Пример #28
0
 /**
  * Stablish a connection to sftp server.
  *
  * @param String $url
  * @param String $username
  * @param String $password
  * 
  * @throws SftpNetworkException
  * @throws SftpAuthenticationException
  *
  * @return ssh2_sftp $connection
  */
 protected function connection($url, $username, $password)
 {
     if (!($connection = @ssh2_connect($url, "22"))) {
         throw new SftpNetworkException("Could not connect to sftp server.");
     }
     if (@ssh2_auth_password($connection, $username, $password) === false) {
         throw new SftpAuthenticationException("Invalid username or password for sftp.");
     }
     return ssh2_sftp($connection);
 }
Пример #29
0
 public function login($username, $password)
 {
     if (!ssh2_auth_password($this->connection, $username, $password)) {
         throw new \Exception("Could not authenticate with username {$username} " . "and password {$password}.");
     }
     $this->sftp = ssh2_sftp($this->connection);
     if (!$this->sftp) {
         throw new \Exception("Could not initialize SFTP subsystem.");
     }
 }
Пример #30
-1
 /**
  * @param Queue $queue
  */
 public function handle(Queue $queueService)
 {
     $waitingQueue = $queueService->getWaiting();
     /**
      * Set queue as started, we'll execute it later.
      */
     $waitingQueue->each(function (QueueRecord $queue) {
         $this->output('#' . $queue->id . ': ' . 'started (' . date('Y-m-d H:i:s') . ')');
         $queue->changeStatus('started');
     }, false);
     /**
      * Execute jobs.
      */
     $waitingQueue->each(function (QueueRecord $queue) {
         $this->output('#' . $queue->id . ': ' . 'running (' . date('Y-m-d H:i:s') . ')');
         $queue->changeStatus('running');
         $this->output('#' . $queue->id . ': ' . $queue->command);
         $output = null;
         $sha1Id = sha1($queue->id);
         try {
             $timeout = strtotime($queue->execute_at) - time();
             $command = $queue->command . ' && echo ' . $sha1Id;
             $lastLine = null;
             if (false && $timeout > 0) {
                 exec('timeout -k 60 ' . $timeout . ' ' . $command, $output);
             } else {
                 if (strpos($command, 'furs:')) {
                     $command = str_replace(['/www/schtr4jh/derive.foobar.si/htdocs/', '/www/schtr4jh/beta.derive.foobar.si/htdocs/'], '/www/schtr4jh/bob.pckg.derive/htdocs/', $command);
                     $connection = ssh2_connect(config('furs.sship'), 22);
                     ssh2_auth_password($connection, config('furs.sshuser'), config('furs.sshpass'));
                     $stream = ssh2_exec($connection, $command);
                     $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
                     stream_set_blocking($errorStream, true);
                     stream_set_blocking($stream, true);
                     $errorStreamContent = stream_get_contents($errorStream);
                     $streamContent = stream_get_contents($stream);
                     $output = $errorStreamContent . "\n" . $streamContent;
                     $lastLine = substr($streamContent, -41, 40);
                 } else {
                     exec($command, $output);
                     $lastLine = end($output);
                 }
             }
             if ($lastLine != $sha1Id) {
                 $queue->changeStatus('failed_permanently', ['log' => 'FAILED: ' . (is_string($output) ? $output : implode("\n", $output))]);
                 return;
                 throw new Exception('Job failed');
             }
         } catch (Throwable $e) {
             $queue->changeStatus('failed_permanently', ['log' => exception($e)]);
             return;
         }
         if (!$output) {
             $queue->changeStatus('failed_permanently', ['log' => 'No output']);
             return;
         }
         $this->output('#' . $queue->id . ': ' . 'finished (' . date('Y-m-d H:i:s') . ')');
         $queue->changeStatus('finished', ['log' => is_string($output) ? $output : implode("\n", $output)]);
     }, false);
 }