felix001
felix001

Reputation: 16691

How do you access the console of a GCE VM instance?

How can I access the console of a Google Compute Engine VM instance?

Upvotes: 4

Views: 6102

Answers (2)

Misha Brukman
Misha Brukman

Reputation: 13424

To see the console output (read-only), you can use any of the following methods:

To get read/write (interactive) access, follow instructions on this page:

gcloud compute instances add-metadata [INSTANCE_NAME] \
    --metadata=serial-port-enable=1

and then, per the same page, either connect via Google Cloud Console:

Go to the VM instances page.

  1. Go to the GCE VM instances page
  2. Click the instance you want to connect to.
  3. Scroll to the bottom of the page and look for the Serial port section.
  4. If you want to connect to a serial port other than the default serial port 1, click the down arrow next to the Connect to serial port button and change the port number accordingly.
  5. Click the Connect to serial port button to connect to port 1 by default. For Windows instances, pull down the dropdown menu next to the button and connect to Port 2 to access the serial console.

or, connect via gcloud:

Use the gcloud compute connect-to-serial-port subcommand to connect using the gcloud command-line tool. For example:

gcloud compute connect-to-serial-port [INSTANCE_NAME]

where [INSTANCE_NAME] is the name of the instance for which you want to access the serial console.

By default, the connect-to-serial-port command connects to port 1 of the serial console. If you are connecting to a Windows VM instance, connect to port 2 instead:

gcloud compute connect-to-serial-port [INSTANCE_NAME] --port 2

To connect to any other port, provide a different port number using the --port flag. You can provide a port number from 1 through 4, inclusively. To learn more about port numbers, see Understanding serial port numbering.

Upvotes: 5

jgoldschrafe
jgoldschrafe

Reputation: 264

While this doesn't answer your direct question, if the reason you need physical console access is to troubleshoot why a system is inaccessible (i.e. it no longer boots or, because of a bad firewall configuration, you can no longer access it over SSH), your best bet is to:

  1. Update the disk configuration so it is not deleted when the instance is destroyed
  2. Delete the instance so the disk is no longer attached to a running instance
  3. Attach the disk to another instance which boots correctly
  4. Mount the disk to a temporary location within that instance, so you can read logs, view/edit configuration files, etc.

Upvotes: 1

Related Questions