Once you are able to access the instance via serial console, you should be able to change the /etc/hosts.deny file of the VM. However, sometimes when you tried to access the instance via
, a login prompt may appear. In that scenario, you need to set-up a local user name and password either by using
1. In the GCP menu go to compute engine and click your instance name.
2. There, click the pencil at the top bar to edit the instance.
3. At the beginning, just down your instance name is check box which says “Enable connecting to serial ports” please enable it.
4. After that, go down to “custom metadata” there add in the “key” textbox this “startup-script” and into the “value” field add next:
#! /bin/bash
useradd -G sudo USERNAME
echo 'USERNAME:PASSWORD' | chpasswd
Please change the values in capital letters for a user name which you like to use, and the password for this user, keep in mind that linux is case sensitive and further you will be prompted to write user and password as was set here.
5. Click save button at the bottom of the page.
6. In the left panel click Metadata. (Here(steps 6-10) I am enabling the interactive serial access at the Project level. If you would like to enable it only for a particular instance, please follow
this guide)
7. There click edit button which is under “Metadata” name section.
8. Click “+Add item”.
9. In “key” field write “serial-port-enable” and in the “value” field write TRUE
10. Click save.
11. Reboot your instance.
12. Once your instance get ready click your instance name.
13. Under “details” you will see two buttons, click the button which says “Connect to serial console”
14. In the new window click enter to enable the console.
15 Enter the user name and password which you set in the startup-script(step number:4),if a login prompt comes.