NAME

WWW::Hetzner::Cloud::API::SSHKeys - Hetzner Cloud SSH Keys API

VERSION

version 0.001

SYNOPSIS

use WWW::Hetzner::Cloud;

my $cloud = WWW::Hetzner::Cloud->new(token => $ENV{HETZNER_API_TOKEN});

# List all SSH keys
my $keys = $cloud->ssh_keys->list;

# Create a new key
my $key = $cloud->ssh_keys->create(
    name       => 'my-key',
    public_key => 'ssh-ed25519 AAAA...',
);

# Key is a WWW::Hetzner::Cloud::SSHKey object
print $key->fingerprint, "\n";

# Update key
$key->name('renamed-key');
$key->update;

# Delete key
$key->delete;

DESCRIPTION

This module provides the API for managing Hetzner Cloud SSH keys. All methods return WWW::Hetzner::Cloud::SSHKey objects.

NAME

WWW::Hetzner::Cloud::API::SSHKeys - Hetzner Cloud SSH Keys API

METHODS

list

my $keys = $cloud->ssh_keys->list;

Returns an arrayref of WWW::Hetzner::Cloud::SSHKey objects.

get

my $key = $cloud->ssh_keys->get($id);

Returns a WWW::Hetzner::Cloud::SSHKey object.

get_by_name

my $key = $cloud->ssh_keys->get_by_name('my-key');

Returns a WWW::Hetzner::Cloud::SSHKey object. Returns undef if not found.

create

my $key = $cloud->ssh_keys->create(
    name       => 'my-key',
    public_key => 'ssh-ed25519 AAAA...',
    labels     => { env => 'prod' },  # optional
);

Creates a new SSH key. Returns a WWW::Hetzner::Cloud::SSHKey object.

update

$cloud->ssh_keys->update($id, name => 'new-name');

Updates SSH key name or labels. Returns a WWW::Hetzner::Cloud::SSHKey object.

delete

$cloud->ssh_keys->delete($id);

Deletes an SSH key.

ensure

my $key = $cloud->ssh_keys->ensure('my-key', $public_key);

Ensures an SSH key exists with the given name and public key content. If a key with that name exists but has different content, it will be deleted and recreated. Returns a WWW::Hetzner::Cloud::SSHKey object.

SUPPORT

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

https://github.com/Getty/p5-www-hetzner

git clone https://github.com/Getty/p5-www-hetzner.git

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.