Reputation: 561
I have a gcloud vm instance of type custom (4 vCPUs, 8 GB memory), with ubuntu 16.04, 10Gb disk space. Today at specific time (7:30 am), start using the 99% of cpu. I restart the machine but continue to use the 99% of cpu. Now I cannot connect through ssh. There is any workaround to connect to my instance and see what the problem is?? Thank you!!!
Upvotes: 1
Views: 466
Reputation: 2065
You could probably try to connect through the serial port :
gcloud compute instances add-metadata INSTANCE --metadata serial-port-enable=1
gcloud compute connect-to-serial-port INSTANCE
Probably the tty on the serial port will be a lot less sensitive to the high CPU usage and you'll be able to log in.
Now, this will ask you for a user and password...what to do if you are (correctly) using only RSA Keypair authentication for ssh? Here there is a quick and dirty hack that does the job:
1 - Set up this as the startup script echo "root:1234" | chpasswd
like this, for example:
gcloud compute instances add-metadata INSTANCE --metadata startup-script='echo "root:1234" | chpasswd'
2 - Reboot the instance so the startup script is applied
3 - Log in through the serial port
gcloud compute connect-to-serial-port INSTANCE
4 - Use root as username and 1234 as password (or whatever you put in the script)
5 - Don't forget to disable serial port access when you don't need it anymore.
Upvotes: 4