Deployer\Server\Remote\NativeSsh::run PHP Method

run() public method

public run ( $command )
    public function run($command)
    {
        $serverConfig = $this->getConfiguration();
        $sshOptions = ['-A', '-q', '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'];
        $username = $serverConfig->getUser() ? $serverConfig->getUser() : null;
        if (!empty($username)) {
            $username = $username . '@';
        }
        $hostname = $serverConfig->getHost();
        if ($serverConfig->getPort()) {
            $sshOptions[] = '-p ' . escapeshellarg($serverConfig->getPort());
        }
        if ($serverConfig->getPrivateKey()) {
            $sshOptions[] = '-i ' . escapeshellarg($serverConfig->getPrivateKey());
        }
        $sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);
        $process = new Process($sshCommand);
        $process->setTimeout(null)->setIdleTimeout(null)->mustRun();
        return $process->getOutput();
    }