Skip to content

SshKey

An SshKey resource manages an SSH public key for authentication to virtual machines. On AWS this is an EC2 Key Pair, on Hetzner an SSH Key, and on DigitalOcean an SSH Key. GCP does not support standalone SSH keys — use the sshPublicKey field directly on Vm instead.

Property Type Required Description
name string yes Unique resource name
id string no Explicit ID (auto-generated UUID if omitted)
provider string no Provider label for multi-provider configs
tags Record<string, string> no Arbitrary key-value metadata
publicKey string yes Public key contents (e.g. ssh-ed25519 AAAA…)
import { SshKey, Vm, Vpc } from '@kykucloud/types'
const myKey = new SshKey({
name: 'deploy-key',
publicKey: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI…',
})
const myVpc = new Vpc({ name: 'my-vpc', cidr: '10.0.0.0/16', region: 'eu-central' })
const server = new Vm({
name: 'web',
instanceType: 'small',
image: 'ubuntu-24.04',
network: myVpc,
sshKey: myKey,
})
Provider Supported Backend
AWS EC2 Key Pair (ImportKeyPairCommand)
GCP Not supported — use sshPublicKey field directly on Vm
Hetzner SSH Key
DigitalOcean SSH Key
  • AWS requires the key to be imported before VM creation. The provider uses ImportKeyPairCommand to upload the public key with a name derived from the SshKey resource name. Pass the key name (not the public key string) to RunInstances.KeyName.
  • GCP throws UnsupportedFeatureError. Set vm.sshPublicKey directly instead — GCP injects it as project-level metadata (ssh-keys).
  • Name length: Hetzner 63 chars, DO 255 chars. Deploy prefix adds 9 characters.