private function generateControlPath(Host $host)
    {
        $port = empty($host->getPort()) ? '' : ':' . $host->getPort();
        $connectionData = "$host$port";
        $tryLongestPossible = 0;
        $controlPath = '';
        do {
            switch ($tryLongestPossible) {
                case 1:
                    $controlPath = "~/.ssh/deployer_%C";
                    break;
                case 2:
                    $controlPath = "~/deployer_$connectionData";
                    break;
                case 3:
                    $controlPath = "~/deployer_%C";
                    break;
                case 4:
                    $controlPath = "~/mux_%C";
                    break;
                case 5:
                    throw new Exception("The multiplexing control path is too long. Control path is: $controlPath");
                default:
                    $controlPath = "~/.ssh/deployer_$connectionData";
            }
            $tryLongestPossible++;
        } while (strlen($controlPath) > 104); // Unix socket max length

        return $controlPath;
    }