Gili
Gili

Reputation: 90023

How does one associate SSH keys with a Google Compute Engine?

I know how to create a Google Compute Engine instance using pulumi, but how does one associate an SSH key with it at creation time?

Upvotes: 2

Views: 329

Answers (1)

Gili
Gili

Reputation: 90023

When creating the instance, you need to set the following metadata pair:

metadata: {
  "enable-oslogin": "false",
  "ssh-keys": username + ":" + sshPublicKey
}

To add multiple SSH keys, separate them with \n.

Enabling OS Login causes metadata-based SSH keys to get disabled: https://serverfault.com/a/1014949/15584

Further reading:

Upvotes: 3

Related Questions