適用対象: Azure Local 2311.2 以降
この記事では、SSH 経由で Secure Shell (SSH) とリモート デスクトップ (RDP) を使用して Azure ローカル VM に接続する例を示します。 この例では、Azure portal と Azure CLI を使用して Arc 拡張機能を使用して OpenSSH サーバーを有効にする方法を示します。
SSH サーバー拡張機能について
ファイアウォールを介して VPN または別の開いているポートを使用せずに、Azure CLI からすべての Windows Server への RDP 接続を開くことができます。 詳細については、 Azure Arc 対応サーバーへの SSH アクセスに関するページを参照してください。
前提 条件
開始する前に、次のことを確認します。
最新バージョンのソフトウェアを実行している Azure Local にアクセスできます。
OpenSSH サーバー拡張機能をインストールします。
OpenSSH サーバー拡張機能は、Azure portal または PowerShell を使用してインストールできます。 Azure portal を使用して拡張機能をインストールすることをお勧めします。
Azure portal を使用して OpenSSH サーバー拡張機能をインストールする
Azure portal を使用して拡張機能をインストールするには、[ 拡張機能 ] に移動し、 OpenSSH for Windows - Azure Arc オプションを選択します。
PowerShell を使用して OpenSSH サーバー拡張機能をインストールする
PowerShell を使用して OpenSSH サーバー拡張機能をインストールするには、次の手順に従います。
管理者として Windows PowerShell セッションを開きます。
次のコマンドレットを実行して、必要な Azure CLI 拡張機能がインストールされていることを確認します。
az extension add --upgrade --name connectedmachine az extension add --upgrade --name ssh
c. Azure にサインインします。
az login --use-device-code
d. 適切なパラメーターを設定します。
$resourceGroup="<your resource group>" $serverName = "<your server name>" $location = "<your location>" $localUser = "<your username>" # Use a local admin account for testing
e.
OpenSSH
Arc 拡張機能をインストールします。az connectedmachine extension create --name WindowsOpenSSH --type WindowsOpenSSH --publisher Microsoft.Azure.OpenSSH --type-handler-version 3.0.1.0 --machine-name $serverName --resource-group $resourceGroup
出力例を次に示します。
PS C:\Users\labadmin> az connectedmachine extension create --name WindowsOpenSSH --location westeurope --type WindowsOpenSSH --publisher Microsoft.Azure.OpenSSH --type-handler-version 3.0.1.0 --machine-name $serverName --resource-group $resourceGroup { "id": "/subscriptions/<SubscriptionName>/resourceGroups/<ResourceGroupName>/providers/<ProviderName>/machines/<MachineName>/extensions/WindowsOpenSSH", "location": "westeurope", "name": "WindowsOpenSSH", "properties": { "autoUpgradeMinorVersion": false, "enableAutomaticUpgrade": true, "instanceView": { "name": "WindowsOpenSSH", "status": { "code": "0", "level": "Information", "message": "Extension Message: OpenSSH Successfully enabled" }, "type": "WindowsOpenSSH", "typeHandlerVersion": "3.0.1.0" }, "provisioningState": "Succeeded", "publisher": "Microsoft.Azure.OpenSSH", "type": "WindowsOpenSSH", "typeHandlerVersion": "3.0.1.0", }, "resourceGroup": "<ResourceGroupName>", "type": "Microsoft.HybridCompute/machines/extensions" } PS C:\Users\labadmin>
f.
WindowsOpenSSH
拡張機能は、Azure portal の拡張機能の一覧ビューで確認できます。
SSH を使用して Azure ローカル VM に接続する
手記
Arc SSH で SSH 用のポート 22 を設定することを許可するように求められる場合があります。
Azure Local に接続するには、次の手順に従います。
次のコマンドを実行して Arc SSH を起動し、サーバーにサインインします。
az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser
これで、SSH 経由で Azure Local に接続されました。
SSH 経由の RDP を使用して Azure ローカル VM に接続する
SSH 経由で RDP を使用して Azure Local にサインインするには、RDP パラメーターを指定して次のコマンドを実行します。
az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser --rdp
SSH 経由で RDP を使用してローカル サーバーにサインインします。
サインインして RDP の認証を行います。
リモート デスクトップ接続のデスクトップを確認できます。
VPN を使用せずに、またはファイアウォールでポートを開かずに、Azure CLI を使用して SSH 経由で Azure Local に RDP トンネルを設定します。