This is your solution
- Go to the VM instances page in Google Cloud Platform console.
- Click on the instance for which you want to add a startup script.
- Click the Edit button at the top of the page.
- Click on ‘Enable connecting to serial ports’
- Under Custom metadata, click Add item.
- Set 'Key' to 'startup-script' and set 'Value' to this script:
#! /bin/bash
useradd -G sudo USERNAME
echo 'USERNAME:PASSWORD' | chpasswd
- Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot.
- Click on 'Connect to serial port' in the page.
- In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt.
10.. Login using the USERNAME and PASSWORD you provided.
From there undo any change that you've done.