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;
    }
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;
    }
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 ; }
Return SSH multiplexing control path

When ControlPath is longer than 104 chars we can get:

SSH Error: unix_listener: too long for Unix domain socket

So try to get as descriptive path as possible.
%C is for creating hash out of connection attributes.

@param Host $host
@return string ControlPath
@throws Exception
Return SSH multiplexing control path