protected function executeRemoteCommand($command, Node $node, Deployment $deployment, $logOutput = true)
    {
        $command = $this->prepareCommand($command);
        $deployment->getLogger()->debug('$' . $node->getName() . ': "' . $command . '"');

        if ($node->hasOption('remoteCommandExecutionHandler')) {
            $remoteCommandExecutionHandler = $node->getOption('remoteCommandExecutionHandler');
            /** @var $remoteCommandExecutionHandler callable */
            return $remoteCommandExecutionHandler($this, $command, $node, $deployment, $logOutput);
        }

        $username = $node->hasOption('username') ? $node->getOption('username') : null;
        if (!empty($username)) {
            $username = $username . '@';
        }
        $hostname = $node->getHostname();

        // TODO Get SSH options from node or deployment
        $sshOptions = ['-A'];
        if ($node->hasOption('port')) {
            $sshOptions[] = '-p ' . escapeshellarg($node->getOption('port'));
        }
        if ($node->hasOption('password')) {
            $sshOptions[] = '-o PubkeyAuthentication=no';
        }
        if ($node->hasOption('privateKeyFile')) {
            $sshOptions[] = '-i ' . escapeshellarg($node->getOption('privateKeyFile'));
        }

        $sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);

        if ($node->hasOption('password')) {
            $passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([dirname(dirname(dirname(__DIR__))), 'Resources', 'Private/Scripts/PasswordSshLogin.expect']);
            if (\Phar::running() !== '') {
                $passwordSshLoginScriptContents = file_get_contents($passwordSshLoginScriptPathAndFilename);
                $passwordSshLoginScriptPathAndFilename = Files::concatenatePaths([$deployment->getTemporaryPath(), 'PasswordSshLogin.expect']);
                file_put_contents($passwordSshLoginScriptPathAndFilename, $passwordSshLoginScriptContents);
            }
            $sshCommand = sprintf('expect %s %s %s', escapeshellarg($passwordSshLoginScriptPathAndFilename), escapeshellarg($node->getOption('password')), $sshCommand);
        }
        $success = $this->executeProcess($deployment, $sshCommand, $logOutput, '    > ');
        if (isset($passwordSshLoginScriptPathAndFilename) && \Phar::running() !== '') {
            unlink($passwordSshLoginScriptPathAndFilename);
        }
        return $success;
    }