kubernetes/kops · error

SSH public key must be specified when running with DigitalOc

Error message

SSH public key must be specified when running with DigitalOcean (create with `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub`)

What it means

On DigitalOcean the SSH key must be uploaded to the provider before droplets can be created, so kOps requires at least one admin sshpublickey secret (or an explicit spec.sshKeyName) when building the DO cluster model; neither was present.

Source

Thrown at upup/pkg/fi/cloudup/apply_cluster.go:441

		AdditionalObjects: c.AdditionalObjects,
	}

	switch cluster.GetCloudProvider() {
	case kops.CloudProviderGCE:
		{
			gceCloud := cloud.(gce.GCECloud)
			project = gceCloud.Project()
		}

	case kops.CloudProviderHetzner:
		{
			// Hetzner Cloud support is currently in beta
		}

	case kops.CloudProviderDO:
		{
			if len(sshPublicKeys) == 0 && (c.Cluster.Spec.SSHKeyName == nil || *c.Cluster.Spec.SSHKeyName == "") {
				return nil, fmt.Errorf("SSH public key must be specified when running with DigitalOcean (create with `kops create secret --name %s sshpublickey admin -i ~/.ssh/id_rsa.pub`)", cluster.ObjectMeta.Name)
			}
		}
	case kops.CloudProviderAWS:
		{
			awsCloud := cloud.(awsup.AWSCloud)

			accountID, partition, err := awsCloud.AccountInfo(ctx)
			if err != nil {
				return nil, err
			}
			modelContext.AWSAccountID = accountID
			modelContext.AWSPartition = partition

			if len(sshPublicKeys) > 1 {
				return nil, fmt.Errorf("exactly one 'admin' SSH public key can be specified when running with AWS; please delete a key using `kops delete secret`")
			}
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Create the admin key secret: `kops create secret --name <cluster> sshpublickey admin -i ~/.ssh/id_rsa.pub`
  2. Alternatively set spec.sshKeyName to an SSH key already registered in DigitalOcean
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/apply_cluster.go:441 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/0e2d9e7a64be1e02. Report an issue: GitHub.