gitlabhq/gitlabhq · error · RemoteMirrors::HostKeysConverter::InvalidHostKeyError

Invalid SSH host key(s): #{invalid_keys.join(', ')}

Error message

Invalid SSH host key(s): #{invalid_keys.join(', ')}

What it means

Error "Invalid SSH host key(s): #{invalid_keys.join(', ')}" thrown in gitlabhq/gitlabhq.

Source

Thrown at app/models/remote_mirrors/host_keys_converter.rb:76

      end

      normalized_keys.join("\n").presence
    end

    private

    attr_reader :host_keys, :url

    def validate!
      raise InvalidHostKeyError, ["too many host keys (maximum is #{MAX_HOST_KEYS})"] if host_keys.size > MAX_HOST_KEYS

      invalid = sanitized_keys.filter_map do |key|
        next if key.blank?

        key unless Gitlab::SSHPublicKey.new(key).valid?
      end

      raise InvalidHostKeyError, invalid if invalid.present?
    end

    def sanitized_keys
      @sanitized_keys ||= host_keys.map do |key|
        sanitize_key(key.to_s.strip)
      end
    end

    def sanitize_key(key)
      parts = Gitlab::SSHPublicKey.extract_key_parts(key)
      return key unless parts

      [parts[:prefix].presence, parts[:algorithm], restore_base64_encoding(parts[:key_data])].compact.join(' ')
    end

    # Form-encoded params (application/x-www-form-urlencoded) decode '+' as spaces.
    # SSH key base64 data uses '+' characters, so we restore them here.
    def restore_base64_encoding(key_data)

View on GitHub (pinned to 55ee20384a)

When it happens

Trigger: Thrown at app/models/remote_mirrors/host_keys_converter.rb:76 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21). Data as JSON: /api/errors/013279a0473ae015. Report an issue: GitHub.