hetzner_robot_rhai/examples/ssh_key_management.rhai

22 lines
1023 B
Plaintext

// Get all SSH keys and print them in a table
let keys = hetzner.get_ssh_keys();
print_ssh_keys_table(keys);
// Get a specific SSH key
// Replace "13:dc:a2:1e:a9:d2:1d:a9:39:f4:44:c5:f1:00:ec:c7" with the fingerprint of the key you want to fetch
let key = hetzner.get_ssh_key("13:dc:a2:1e:a9:d2:1d:a9:39:f4:44:c5:f1:00:ec:c7");
print(key);
// Add a new SSH key
// Replace "my-new-key" with the desired name and "ssh-rsa ..." with your public key data
let new_key = hetzner.add_ssh_key("my-new-key", "ssh-rsa ...");
print(new_key);
// Update an SSH key's name
// Replace "cb:8b:ef:a7:fe:04:87:3f:e5:55:cd:12:e3:e8:9f:99" with the fingerprint of the key you want to update
let updated_key = hetzner.update_ssh_key_name("cb:8b:ef:a7:fe:04:87:3f:e5:55:cd:12:e3:e8:9f:99", "my-updated-key-name");
print(updated_key);
// Delete an SSH key
// Replace "cb:8b:ef:a7:fe:04:87:3f:e5:55:cd:12:e3:e8:9f:99" with the fingerprint of the key you want to delete
hetzner.delete_ssh_key("cb:8b:ef:a7:fe:04:87:3f:e5:55:cd:12:e3:e8:9f:99");