連線至 Windows VM 的 SAC


本文說明如何連線至 Windows Special Administrative Console (SAC)。SAC 會使用序列埠連線至 Windows 虛擬機器 (VM) 執行個體,且不依賴網路連線,因此有助於排解或復原 Windows VM 執行個體。您可以連線至 VM 的序列主控台並使用 SAC,中斷 VM 的開機程序,或取得 CMD 或 PowerShell 終端機的存取權,以便進行疑難排解。如要使用一般用途的遠端桌面體驗 (不含疑難排解),請使用 RDP 連線至 Windows VM

事前準備

  • 您必須先啟用 VM 的互動式存取權,才能使用互動式序列控制台連線至 VM 的 SAC。詳情請參閱「啟用對序列主控台的互動式存取權」。
  • 如果尚未設定,請先設定驗證機制。驗證是指驗證身分,以便存取 Google Cloud 服務和 API 的程序。如要在本機開發環境中執行程式碼或範例,您可以選取下列任一選項,向 Compute Engine 進行驗證:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. After installing the Google Cloud CLI, initialize it by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.

連線至序列主控台

如要使用互動式序列主控台連線至 Windows 執行個體,請按照下列分頁中的步驟進行。

主控台

  1. 前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面

    前往 VM 執行個體

  2. 按一下要連線的 VM 名稱。

  3. 按一下「Connect to serial console」,即可開啟互動式主控台。

互動式序列主控台會隨即開啟。當您看到以下輸出內容時,就表示可以使用:

Computer is booting, SAC started and initialized.

Use the "ch -?" command for information about using channels.
Use the "?" command for general help.

SAC>

如果互動式序列主控台畫面空白,且只有閃爍的游標,可能是因為緊急管理服務已關閉。請參閱互動式序列主控台疑難排解,瞭解如何解決這個問題。

gcloud

使用 gcloud compute connect-to-serial-port 指令連線至已啟用序列埠存取權的 VM 執行個體:

gcloud compute connect-to-serial-port VM_NAME \
    --port=2 \
    --zone=ZONE \
    --project=PROJECT_ID

更改下列內容:

  • PROJECT_ID:包含 VM 的專案 ID
  • ZONE:VM 所在的可用區名稱
  • VM_NAME:VM 名稱

互動式序列主控台會隨即開啟。當您看到以下輸出內容時,就表示可以使用:

Computer is booting, SAC started and initialized.

Use the "ch -?" command for information about using channels.
Use the "?" command for general help.

SAC>

如果互動式序列主控台畫面空白,且只有閃爍的游標,可能是因為緊急管理服務已關閉。請參閱互動式序列主控台疑難排解,瞭解如何解決這個問題。

如要進一步瞭解如何使用互動式序列主控台,請參閱 Microsoft 的 SAC 指令說明文件

在 Windows SAC 中開啟命令提示字元

如要在 SAC 中開啟命令提示字元,請按照下列步驟操作:

  1. 輸入 cmd,然後按下 Enter 鍵。您會看見以下輸出內容:

    SAC>cmd
    The Command Prompt session was successfully launched.
    SAC>
    EVENT:   A new channel has been created.  Use "ch -?" for channel help.
    Channel: Cmd0001
    SAC>
    
  2. 使用 ch -sn CHANNEL_NAME 指令,然後按下 Enter 鍵。

    ch -sn CHANNEL_NAME
    

    CHANNEL_NAME 替換為您在上一個步驟中建立的管道名稱。

    輸出結果會與下列內容相似:

    Name:                  Cmd0001
    Description:           Command
    Type:                  VT-UTF8
    Channel GUID:          28de7392-5413-11ea-bb03-c9656a2ed613
    Application Type GUID: 63d02271-8aa4-11d5-bccf-00b0d014a2d0
    
    Press <esc><tab> for next channel.
    Press <esc><tab>0 to return to the SAC channel.
    Use any other key to view this channel.
    
  3. 按下 空格鍵,然後使用系統中註冊的本機憑證登入。

    Please enter login credentials.
    Username: USERNAME
    Domain: DOMAIN (leave blank if no domain)
    Password: PASSWORD
    

    連線後,您就能使用命令提示字元殼層。

    Microsoft Windows [Version 10.0.14393]
    (c) 2016 Microsoft Corporation. All rights reserved.
    
    C:\Windows\system32>
    
  4. 選用:如要輸入 Powershell 提示,請輸入 powershell.exe,然後按下 Enter 鍵。

後續步驟