共用方式為


針對已啟用 Azure Arc 的伺服器 SSH 存取進行疑難排解 \(部分機器翻譯\)

本文針對嘗試透過 SSH 連線至已啟用 Azure Arc 的伺服器時可能發生的問題,提供疑難排解和解決方法的相關資訊。 如需一般資訊,請參閱已啟用 Arc 的伺服器 SSH 存取概觀

用戶端問題

這些問題的原因是使用者用來連線的機器上所發生的錯誤。

找不到用戶端二進位檔

找不到連線所需的用戶端 SSH 二進位檔時,就會發生此問題。 可能的錯誤:

  • Failed to create ssh key file with error: \<ERROR\>.
  • Failed to run ssh command with error: \<ERROR\>.
  • Failed to get certificate info with error: \<ERROR\>.
  • Failed to create ssh key file with error: [WinError 2] The system cannot find the file specified.
  • Failed to create ssh key file with error: [Errno 2] No such file or directory: 'ssh-keygen'.

解決方法:

  • 使用 --ssh-client-folder 參數,提供包含 SSH 用戶端可執行檔的資料夾路徑。
  • 確定資料夾位於 Azure PowerShell 的 PATH 環境變數中

Azure PowerShell 模組版本不相符

當已安裝的 Az.Ssh 版本不支援已安裝的 Azure PowerShell 子模組 Az.Ssh.ArcProxy 時,就會發生此問題。 錯誤:

  • This version of Az.Ssh only supports version 1.x.x of the Az.Ssh.ArcProxy PowerShell Module. The Az.Ssh.ArcProxy module {ModulePath} version is {ModuleVersion}, and it is not supported by this version of the Az.Ssh module. Check that this version of Az.Ssh is the latest available.

解決方法:

  • 更新 Az.Ssh 和 Az.Ssh.ArcProxy 模組

未安裝 Az.Ssh.ArcProxy

在用戶端電腦上找不到 Proxy 模組時,就會發生此問題。 錯誤:

  • Failed to find the PowerShell module Az.Ssh.ArcProxy installed in this machine. You must have the Az.Ssh.Proxy PowerShell module installed in the client machine in order to connect to Azure Arc resources. You can find the module in the PowerShell Gallery (see: https://aka.ms/PowerShellGallery-Az.Ssh.ArcProxy).

解決方法:

使用者沒有執行 Proxy 的權限

當使用者沒有權限執行用來連線的 SSH Proxy 時,就會發生此問題。 錯誤:

  • /bin/bash: line 1: exec: /usr/local/share/powershell/Modules/Az.Ssh.ArcProxy/1.0.0/sshProxy_linux_amd64_1.3.022941: cannot execute: Permission denied
  • CreateProcessW failed error:5 posix_spawnp: Input/output error

解決方法:

  • 確定使用者具有執行 Proxy 檔案的權限。

伺服器端問題

無法在公開預覽之後連線

如果使用者已參與公開預覽,且已將其 Arc 代理程式和 Azure CLI/PowerShell 更新為正式發行版本,則連線可能會失敗。

解決方法:

伺服器上不允許 SSH 流量

如果伺服器上未執行 SSHD,或伺服器上不允許 SSH 流量,則會發生此問題。 錯誤:

  • {"level":"fatal","msg":"sshproxy: error copying information from the connection: read tcp 192.168.1.180:60887-\u003e40.122.115.96:443: wsarecv: An existing connection was forcibly closed by the remote host.","time":"2022-02-24T13:50:40-05:00"}
  • {"level":"fatal","msg":"sshproxy: error connecting to the address: 503 connection to localhost:22 failed: dial tcp [::1]:22: connectex: No connection could be made because the target machine actively refused it.. websocket: bad handshake","proxyVersion":"1.3.022941"}
  • SSH connection is not enabled in the target port {Port}.

解決方法:

  • 確定正在已啟用 Arc 的伺服器上執行 SSHD 服務。
  • 確定已啟用 Arc 的伺服器在連接埠 22 (或其他非預設連接埠) 上啟用此功能

az rest --method put --uri https://management.azure.com/subscriptions/<subscription>/resourceGroups/<resourcegroup>/providers/Microsoft.HybridCompute/machines/<arc enabled server name>/providers/Microsoft.HybridConnectivity/endpoints/default/serviceconfigurations/SSH?api-version=2023-03-15 --body '{\"properties\": {\"serviceName\": \"SSH\", \"port\": \"22\"}}'

Azure 權限問題

用以啟用 SSH 連線能力的角色指派不正確

當目前使用者沒有適當的角色指派來對目標資源做出貢獻時,就會發生此問題。 錯誤:

  • Client is not authorized to create a Default connectivity endpoint for {Name} in the Resource Group {ResourceGroupName}. This is a one-time operation that must be performed by an account with Owner or Contributor role to allow connections to target resource

解決方法:

  • 確定您在資源上具有擁有者或參與者角色,或連絡資源的擁有者/參與者以設定 SSH 連線。

要連線的角色指派不正確

當目前的使用者在目標資源上不具適當的角色指派時 (特別是缺少 read 權限時),就會發生此問題。 可能的錯誤:

  • Unable to determine the target machine type as Azure VM or Arc Server
  • Unable to determine that the target machine is an Arc Server
  • Unable to determine that the target machine is an Azure VM
  • Permission denied (publickey).
  • Request for Azure Relay Information Failed: (AuthorizationFailed) The client '\<user name\>' with object id '\<ID\>' does not have authorization to perform action 'Microsoft.HybridConnectivity/endpoints/listCredentials/action' over scope '/subscriptions/\<Subscription ID\>/resourceGroups/\<Resource Group\>/providers/Microsoft.HybridCompute/machines/\<Machine Name\>/providers/Microsoft.HybridConnectivity/endpoints/default' or the scope is invalid. If access was recently granted, please refresh your credentials.

解決方法:

  • 確定您在所連線的資源上具有虛擬機器本機使用者登入角色。 如果使用 Microsoft Entra 登入,請確定您擁有虛擬機器使用者登入或虛擬機器系統管理員登入角色,且 Microsoft Entra SSH 登入延伸模組已安裝在已啟用 Arc 的伺服器上。

未註冊 HybridConnectivity RP

未註冊訂用帳戶的 HybridConnectivity 資源提供者時,就會發生此問題。 錯誤:

  • Azure 轉送資訊的要求失敗: (NoRegisteredProviderFound) 程式碼: NoRegisteredProviderFound

解決方法:

  • az provider register -n Microsoft.HybridConnectivity執行
  • 執行 az provider show -n Microsoft.HybridConnectivity 以確認成功,並確認 registrationState 已設定為 Registered
  • 在已啟用 Arc 的伺服器上重新啟動混合式代理程式

更新 CLI 工具和 Arc 代理程式之後無法連線

當已更新的命令在更新 Arc 代理程式之前建立新的服務組態時,就會發生此問題。 這只會在更新至 1.31 版或更新版本時影響 1.31 之前的 Azure Arc 版本。 錯誤:

  • 未知連接埠 65535 關閉連線

    解決方法:

    • 刪除現有的服務組態,並允許它在下一次連線時由 CLI 命令重新建立。 az rest --method delete --uri https://management.azure.com/subscriptions/<SUB_ID>/resourceGroups/<RG_NAME>/providers/Microsoft.HybridCompute/machines/<VM_NAME>/providers/Microsoft.HybridConnectivity/endpoints/default/serviceconfigurations/SSH?api-version=2023-03-15執行

停用已啟用 Arc 的伺服器的 SSH

完成下列動作,可停用此功能:

  • 從已啟用 Arc 的伺服器移除 SSH 連接埠和功能:az rest --method delete --uri https://management.azure.com/subscriptions/<subscription>/resourceGroups/<resourcegroup>/providers/Microsoft.HybridCompute/machines/<arc enabled server name>/providers/Microsoft.HybridConnectivity/endpoints/default/serviceconfigurations/SSH?api-version=2023-03-15 --body '{\"properties\": {\"serviceName\": \"SSH\", \"port\": \"22\"}}'

  • 刪除預設連線端點:az rest --method delete --uri https://management.azure.com/subscriptions/<subscription>/resourceGroups/<resourcegroup>/providers/Microsoft.HybridCompute/machines/<arc enabled server name>/providers/Microsoft.HybridConnectivity/endpoints/default?api-version=2023-03-15

下一步