public function copyFiles($source, $target, $setPermissions = false)
    {
        if (strpos($target, ':') !== false && strpos($target, '@') !== false) {
            if (is_dir($source)) {
                $source .= "/.";
            }
            $command = "scp -rp " . escapeshellarg($source) . " " . escapeshellarg($target);
            if ($setPermissions) {
                $command = "rsync -rp --perms --chmod=u+rwx,g+rwx,o+rwx " . escapeshellarg($source) . " " . escapeshellarg($target);
            }
        } else {
            $command = "cp -frT " . escapeshellarg($source) . " " . escapeshellarg($target);
            if ($setPermissions) {
                $command .= " && chmod 777 " . escapeshellarg($target);
            }
        }
        $this->executeCommand($command);
    }