0
votes

Friends good night.

I have a server on Google Compute Engine, which I do not have access to via ssh and the old administrator did not leave access to it.

Is there any possibility to access this server either through SDK, GCP Console, etc.?

Thank you very much in advance.

2
What have you tried? What errors have you received? Start with the Google Cloud Console for Compute Engine. You will find a button to connect via SSH provided you have the correct permissions (roles). - John Hanley
Do you have a full access to the project? - guillaume blaquiere

2 Answers

0
votes

If you or your team have an IAM account on the project with sufficient roles/permissions (Owner, ComputeAdmin), you can try the following:

  • Check this troubleshooting documentation in order to identify and solve your issue

  • Try to access the VM through the SerialPort.

0
votes

I had mistakenly locked myself via these files /etc/hosts.allow and /etc/hosts.deny. It took me a day to get back access to the server and I hope below will help someone locked out of a GCP vm. It simply creates a script that runs when your VM is booting up. You can then have all commands to fix your issue run without direct access to the server. Below is how you can for example reset root password.

I am assuming that you have access to GCP console via browser, do below:-

  1. Shutdown the server

  2. Click on edit and scroll down to Custom metadata. Add a new item with key as startup-script and the value as below. Replace yournewpassword with the password you want to set for the root user:

    #!/bin/sh echo "yournewpassword:root" | chpasswd

  3. Reboot your server and use your new password set above to ssh to your vm

  4. Remove the meta and save your VM. You can reboot again.