如何访问 GCE VM 实例的控制台?
How do you access the console of a GCE VM instance?
如何访问 Google Compute Engine VM 实例的控制台?
要查看控制台输出(只读),您可以使用以下任何一种方法:
- Web UI via Developers Console – 在实例详细信息页面上,滚动到页面底部并展开控制台输出视图
- CLI 通过
gcloud compute instances get-serial-port-output
- API 通过
getSerialPortOutput
要获得 read/write(交互式)访问权限,请按照 this page 上的说明进行操作:
gcloud compute instances add-metadata [INSTANCE_NAME] \
--metadata=serial-port-enable=1
然后,根据 the same page,通过 Google 云端控制台连接:
Go to the VM instances page.
- Go to the GCE VM instances page
- Click the instance you want to connect to.
- Scroll to the bottom of the page and look for the Serial port section.
- 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.
- 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.
或者,通过 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.
虽然这不能回答您的直接问题,但如果您需要物理控制台访问权限的原因是为了解决系统无法访问的原因(即它不再启动,或者由于防火墙配置错误,您无法再通过 SSH 访问它),你最好的选择是:
- 更新磁盘配置,使其在实例销毁时不被删除
- 删除实例,使磁盘不再附加到 运行 个实例
- 将磁盘附加到另一个正确启动的实例
- 将磁盘安装到该实例中的临时位置,以便您可以读取日志、view/edit 配置文件等。
如何访问 Google Compute Engine VM 实例的控制台?
要查看控制台输出(只读),您可以使用以下任何一种方法:
- Web UI via Developers Console – 在实例详细信息页面上,滚动到页面底部并展开控制台输出视图
- CLI 通过
gcloud compute instances get-serial-port-output
- API 通过
getSerialPortOutput
要获得 read/write(交互式)访问权限,请按照 this page 上的说明进行操作:
gcloud compute instances add-metadata [INSTANCE_NAME] \ --metadata=serial-port-enable=1
然后,根据 the same page,通过 Google 云端控制台连接:
Go to the VM instances page.
- Go to the GCE VM instances page
- Click the instance you want to connect to.
- Scroll to the bottom of the page and look for the Serial port section.
- 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.
- 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.
或者,通过 gcloud
连接:
Use the
gcloud compute connect-to-serial-port
subcommand to connect using thegcloud
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.
虽然这不能回答您的直接问题,但如果您需要物理控制台访问权限的原因是为了解决系统无法访问的原因(即它不再启动,或者由于防火墙配置错误,您无法再通过 SSH 访问它),你最好的选择是:
- 更新磁盘配置,使其在实例销毁时不被删除
- 删除实例,使磁盘不再附加到 运行 个实例
- 将磁盘附加到另一个正确启动的实例
- 将磁盘安装到该实例中的临时位置,以便您可以读取日志、view/edit 配置文件等。