監視及管理遠端工作階段

已完成

在此單元中,您將了解如何透過啟用診斷記錄並監視遠端工作階段來管理遠端工作階段。

設定診斷設定以產生稽核記錄

Azure Bastion 可記錄遠端使用者工作階段的資訊。 您可以檢閱這些記錄以查看有誰連線到哪一個工作負載、連線時間、連線位置,以及其他相關記錄資訊。

若要產生這些記錄,您必須在 Azure Bastion 上設定診斷設定。 記錄可能需要花費數個小時才能串流到儲存體帳戶。 下列各節會說明如何設定 Azure Bastion 診斷設定,以便您稍後在自己的訂閱中嘗試。

為 Azure Bastion 啟用診斷

在 Azure Bastion 資源中,您可在 [監視] 下新增診斷設定。 您需要儲存體帳戶以將記錄串流到其中。 如果還沒有儲存體帳戶,請先建立一個,再於自己的訂閱中嘗試這些步驟。

  1. Azure 入口網站中,搜尋或選取 [Bastions]

  2. 選取 Azure Bastion 資源。

  3. 在 [監視] 底下,選取 [診斷設定]

  4. 選取 [新增診斷設定]。

    Screenshot that shows the Add diagnostic settings link within the Diagnostics settings page.

  5. 針對 [診斷設定名稱] 輸入名稱。

  6. 在 [記錄] 底下,核取 [Bastion 稽核記錄] 的方塊。

  7. 在 [目的地詳細資料] 底下,選取 [傳送至 Log Analytics] 和 [封存至儲存體帳戶]

  8. 系統會自動填入位置、訂用帳戶及儲存體帳戶。 請確定儲存體帳戶和 Azure Bastion 資源位於相同的區域。

    Screenshot that shows the Diagnostics setting page filled out.

  9. 選取 [儲存]。

  10. 儲存完成後,請關閉頁面。

檢視診斷記錄

診斷記錄需要花費數個小時才會出現在您的儲存體帳戶中。 您可以在儲存體帳戶的 [容器] 底下找到這些記錄。

Screenshot of a storage account with a container called insights-logs-bastionauditlogs.

向下鑽研資源階層資料夾以取得 Azure Bastion 主機檔案。

Screenshot of the insights logs for Azure Bastion that shows the folder location level is at the Azure Bastion host resource.

繼續向下鑽研年 (y=)、月 (m=)、日 (d=)、小時 (h=) 及分鐘 (m=) 資料夾,找到特定時段的診斷記錄資料。

Screenshot of the insights logs for Azure Bastion that shows the J S O N file for a specific time period.

請下載 .json 檔案以檢視工作階段詳細資料。 開啟的檔案看起來會類似下列範例。 在範例中,您會看到作業類型、使用者名稱和用戶端 IP 位址等資訊。

{ 
"time":"2020-10-22T23:26:00.697Z",
"resourceId":"/SUBSCRIPTIONS/<subscripionID>/RESOURCEGROUPS/MYBASTION/PROVIDERS/MICROSOFT.NETWORK/BASTIONHOSTS/MYBASTION-BASTION",
"operationName":"Microsoft.Network/BastionHost/connect",
"category":"BastionAuditLogs",
"level":"Informational",
"location":"westus2",
"properties":{ 
   "userName":"<username>",
   "userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
   "clientIpAddress":"131.107.159.86",
   "clientPort":24039,
   "protocol":"ssh",
   "targetResourceId":"/SUBSCRIPTIONS/<subscripionID>/RESOURCEGROUPS/MYBASTION/PROVIDERS/MICROSOFT.COMPUTE/VIRTUALMACHINES/LINUX-KEY",
   "subscriptionId":"<subscripionID>",
   "message":"Successfully Connected.",
   "resourceType":"VM",
   "targetVMIPAddress":"172.16.1.5",
   "tunnelId":"<tunnelID>"
},
"FluentdIngestTimestamp":"2020-10-22T23:26:00.0000000Z",
"Region":"westus2",
"CustomerSubscriptionId":"<subscripionID>"
}

管理目前的遠端工作階段

Azure Bastion 工作階段監視可供檢視哪些使用者連線到哪些虛擬機器。 其顯示使用者連線的 IP、已連線的時間長度,以及進行連線的時間。 您可以選取正在進行的工作階段,並強制中斷該工作階段的連線,以中斷使用者與該工作階段之間的連線。

Screenshot of the Azure Bastion sessions page with the delete option selected for one of the two sessions.

您將在下一個單元中逐步了解如何管理遠端工作階段。