protected function getNewKeyPath($number = 1)
    {
        $basename = self::DEFAULT_BASENAME;
        if ($number > 1) {
            $basename = strpos($basename, '.key')
                ? str_replace('.key', '.' . $number . 'key', $basename)
                : $basename . '.' . $number;
        }
        /** @var \Platformsh\Cli\Service\Filesystem $fs */
        $fs = $this->getService('fs');
        $filename = $fs->getHomeDirectory() . '/.ssh/' . $basename;
        if (file_exists($filename)) {
            return $this->getNewKeyPath(++$number);
        }

        return $filename;
    }
protected function getNewKeyPath($number = 1)
    {
        $basename = self::DEFAULT_BASENAME;
        if ($number > 1) {
            $basename = strpos($basename, '.key')
                ? str_replace('.key', '.' . $number . 'key', $basename)
                : $basename . '.' . $number;
        }
        /** @var \Platformsh\Cli\Service\Filesystem $fs */
        $fs = $this->getService('fs');
        $filename = $fs->getHomeDirectory() . '/.ssh/' . $basename;
        if (file_exists($filename)) {
            return $this->getNewKeyPath(++$number);
        }

        return $filename;
    }
protected function getNewKeyPath ( $ number = 1 ) { $ basename = self :: DEFAULT_BASENAME ; if ( $ number > 1 ) { $ basename = strpos ( $ basename , '.key' ) ? str_replace ( '.key' , '.' . $ number . 'key' , $ basename ) : $ basename . '.' . $ number ; } /** @var \Platformsh\Cli\Service\Filesystem $fs */ $ fs = $ this -> getService ( 'fs' ) ; $ filename = $ fs -> getHomeDirectory ( ) . '/.ssh/' . $ basename ; if ( file_exists ( $ filename ) ) { return $ this -> getNewKeyPath ( ++ $ number ) ; } return $ filename ; }
Find the path for a new SSH key.

If the file already exists, this will recurse to find a new filename. The
first will be "id_rsa", the second "id_rsa2", the third "id_rsa3", and so
on.

@param int $number

@return string
Find the path for a new SSH key .