Hetzner hcloud Python使用SSH密钥创建服务器

Hetzner hcloud Python使用SSH密钥创建服务器,python,api,ssh-keys,hcloud,Python,Api,Ssh Keys,Hcloud,我想用Hetzner hcloud Python库创建一个服务器。 如何注入SSH密钥?我已经创建了一个名为“SSH密钥”的SSH密钥 我找不到如何使用SSH密钥完成此工作的AxSample。您需要传递SSH密钥列表,即:client.SSH\u Keys.get\u list() 2021-01-30的完整工作示例: 来自hcloud导入客户端的 从hcloud.images.domain导入图像 从hcloud.locations.domain导入位置 从hcloud.server\u t

我想用Hetzner hcloud Python库创建一个服务器。

如何注入SSH密钥?我已经创建了一个名为“SSH密钥”的SSH密钥


我找不到如何使用SSH密钥完成此工作的AxSample。

您需要传递SSH密钥列表,即:
client.SSH\u Keys.get\u list()

2021-01-30的完整工作示例:

来自hcloud导入客户端的

从hcloud.images.domain导入图像
从hcloud.locations.domain导入位置
从hcloud.server\u types.domain导入服务器类型
client=client(“此处为您的api密钥”)
ssh=client.ssh\u keys.get\u by\u name(“ssh\u key\u name\u set\u on\u hetzner”)
响应=client.servers.create(
name=“示例服务器名称”,
位置=位置(name=“nbg1”),
服务器类型=服务器类型(“cx11”),
image=image(name=“debian-10”),
ssh_密钥=[ssh],
)
from hcloud import Client
from hcloud.images.domain import Image
from hcloud.server_types.domain import ServerType

client = Client(token="I7................I")  # Please paste your API token here between the quotes
response = client.servers.create(name="my-server", server_type=ServerType("cx11"), image=Image(name="ubuntu-18.04"), ssh_keys=ssh_keys(name=(["SSH-Key"])))
server = response.server
print(server)