To use an SSH key to access a virtual machine, the SSH key must be extracted from the virtual machine's metadata. The easiest way to ensure that this happens is to add the SSH key to the server's metadata before the virtual machine is first booted. The firstboot script should then extract the SSH key from the virtual machine's metadata.