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?
Asked
Active
Viewed 208 times
1 Answers
4
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:

Gili
- 86,244
- 97
- 390
- 689