Search code examples
pythongoogle-compute-enginelibcloud

Creating sshKeys for gce instance using libcloud


I need help! I am trying to create sshKeys(protocol pub_key username) for gce instance using libcloud API create_node with parameter ex_metadata while creating an instance. But username value is not getting saved when I check in google cloud console after the creation of instance.

Is there any different format to send sshKeys for metadata? I am sending data like this,

metadata = {"items": [{"value": value, "key": "sshKeys"}]}

Solution

  • I'm not familiar with libcloud, however if you were using the gcloud compute instances create and you want to pass SSH keys with the flag --metadata KEY=VALUE, you need to do it as

    -–metadata “sshKeys=username:ssh-rsaAAAAADAQABA.....".

    So it might be something like:

    metadata = {"items": [{"value": username:ssh-rsaAAAAADAQABA....., "key": "sshKeys"}]}