'Hetzner HCloud Python 创建服务器并使用 SSH-Keys'

2024-09-28 03:23:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用Hetzner-hcloudpython库创建一个服务器。 https://github.com/hetznercloud/hcloud-python

如何注入SSH密钥?我已经创建了一个名为“SSH Key”的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)

我找不到一个axsample如何得到这项工作与SSH密钥。你知道吗


Tags: keynamefromimageimportclienttokenserver

热门问题