hashicorp/vagrant · error · Vagrant::Errors::SSHKeyTypeNotSupportedByServer

The private key you are attempting to generate is not suppor

Error message

The private key you are attempting to generate is not supported by
the guest SSH server. Please use one of the available key types defined
below that is supported by the guest SSH server.

Requested: %{requested_key_type}
Available: %{available_key_types}

What it means

With `config.ssh.key_type = :auto` (the default), the SSH communicator probes the guest SSH server for supported key algorithms. If none of the preferred key types (Vagrant::Util::Keypair::PREFER_KEY_TYPES, e.g. ed25519/rsa variants) is supported, detection yields nil and SSHKeyTypeNotSupportedByServer is raised with requested type ':auto' and the available types listed. This is the :auto branch of the key-type check during insecure-key replacement.

Source

Thrown at plugins/communicators/ssh/communicator.rb:221

                  end
                  nil
                rescue => err
                  @logger.warn("Failed to check key types server supports: #{err}")
                  nil
                end
              end

              @logger.debug("Detected key type for new private key: #{key_type}")

              # If no key type was discovered, default to rsa
              if key_type.nil?
                @logger.debug("Failed to detect supported key type in: #{supported_key_types.join(", ")}")
                available_types = supported_key_types.map { |t|
                  next if !Vagrant::Util::Keypair::PREFER_KEY_TYPES.key?(t)
                  "#{t} (#{Vagrant::Util::Keypair::PREFER_KEY_TYPES[t]})"
                }.compact.join(", ")

                raise Vagrant::Errors::SSHKeyTypeNotSupportedByServer,
                      requested_key_type: ":auto",
                      available_key_types: available_types
              end
            else
              type_name = Vagrant::Util::Keypair::PREFER_KEY_TYPES.key(key_type)
              if !supports_key_type?(type_name)
                available_types = supported_key_types.map { |t|
                  next if !Vagrant::Util::Keypair::PREFER_KEY_TYPES.key?(t)
                  "#{t} (#{Vagrant::Util::Keypair::PREFER_KEY_TYPES[t]})"
                }.compact.join(", ")
                raise Vagrant::Errors::SSHKeyTypeNotSupportedByServer,
                      requested_key_type: "#{type_name} (#{key_type})",
                      available_key_types: available_types
              end
            end
          rescue ServerDataError
            @logger.warn("failed to load server data for key type check")
            if key_type.nil? || key_type == :auto

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Set an explicit broadly-supported type: `config.ssh.key_type = 'rsa'`, then `vagrant reload`
  2. Upgrade the guest's OpenSSH so it advertises modern key types (ed25519 needs OpenSSH >= 6.5)
  3. If probing failed spuriously, fix guest connectivity and reload — on ServerDataError Vagrant falls back to RSA automatically

Example fix

# before
Vagrant.configure('2') do |config|
  config.vm.box = 'ancient-box'
  # key_type defaults to :auto -> detection finds nothing
end

# after
Vagrant.configure('2') do |config|
  config.vm.box = 'ancient-box'
  config.ssh.key_type = 'rsa'
end
Defensive patterns

Strategy: fallback

Validate before calling

algs = `vagrant ssh -c 'sshd -T 2>&1 | grep -i hostkeyalgorithms'`
puts algs  # confirm ed25519/rsa appear before relying on :auto key type

Try / catch

begin
  env.cli('up')
rescue Vagrant::Errors::SSHKeyTypeNotSupportedByServer => e
  warn "supported: #{e.extra_data[:available_key_types]}"
  # pin config.ssh.key_type = 'rsa' in the Vagrantfile, then `vagrant reload`
end

Prevention

When it happens

Trigger: A guest sshd so old or restricted that its advertised algorithms intersect none of Vagrant's preferred key types; probing that fails for every candidate so the catch(:key_type) loop returns nil.

Common situations: Ancient boxes with early OpenSSH; dropbear-based appliances without ed25519; corporate-hardened sshd images restricting key algorithms; guests where SSH banner/algorithm probing is flaky.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/918f1232017afc7b. Report an issue: GitHub.