|
| 1 | +--- |
| 2 | +title: Connect to an Arc VM on Azure Local using SSH |
| 3 | +description: Learn how to use SSH to connect to an Arc VM on Azure Local. |
| 4 | +author: alkohli |
| 5 | +ms.author: alkohli |
| 6 | +ms.topic: how-to |
| 7 | +ms.service: azure-local |
| 8 | +ms.date: 02/11/2025 |
| 9 | + |
| 10 | +#customer intent: As a Senior Content Developer, I want to provide customers with the highest level of content for using disconneced operations to deploy and manage their Azure Local instances. |
| 11 | +--- |
| 12 | + |
| 13 | +# Connect to an Arc VM on Azure Local using SSH and RDP over SSH |
| 14 | + |
| 15 | +[!INCLUDE [hci-applies-to-23h2](../includes/hci-applies-to-23h2.md)] |
| 16 | + |
| 17 | +This article provides an example to connect to an Azure Arc VM on Azure Local using Secure Shell (SSH) and Remote Desktop (RDP) over SSH. The example demonstrates enabling the OpenSSH Server via the Arc Extension using Azure portal and Azure CLI. |
| 18 | + |
| 19 | +## More about the SSH Server Extension |
| 20 | + |
| 21 | +You can open an RDP connection to every Windows Server from the Azure CLI without a VPN or another open port through your firewall. For more information, see [SSH access to Azure Arc-enabled servers](/azure/azure-arc/servers/ssh-arc-overview?tabs=azure-cli). |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +Before you begin, ensure that you: |
| 26 | + |
| 27 | +1. Have access to Azure Local that is running the latest version of software. |
| 28 | + |
| 29 | +1. Install the OpenSSH Server Extension. |
| 30 | + |
| 31 | + You can install the OpenSSH Server Extension via Azure portal or using PowerShell. Installing the extension via Azure portal is the recommended method. |
| 32 | + |
| 33 | + ### Install the OpenSSH Server Extension via Azure portal |
| 34 | + |
| 35 | + To install the extension via Azure portal, navigate to **Extensions** and select the **OpenSSH for Windows - Azure Arc** option. |
| 36 | + |
| 37 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/install-open-ssh-server-1.png" alt-text="Screenshot of the Azure Arc Extensions page." lightbox="./media/connect-arc-vm-using-ssh/install-open-ssh-server-1.png"::: |
| 38 | + |
| 39 | + ### Install the OpenSSH Server Extension via PowerShell |
| 40 | + |
| 41 | + Use the following steps to install the OpenSSH Server Extension via PowerShell: |
| 42 | + |
| 43 | + 1. Open a Windows PowerShell session as an administrator. |
| 44 | + |
| 45 | + 1. Run the following cmdlets to ensure that the required Azure CLI Extensions are installed: |
| 46 | + |
| 47 | + ```powershell |
| 48 | + az extension add --upgrade --name connectedmachine |
| 49 | + az extension add --upgrade --name ssh |
| 50 | + ``` |
| 51 | + |
| 52 | + c. Sign in to Azure: |
| 53 | + |
| 54 | + ```powershell |
| 55 | + az login --use-device-code |
| 56 | + ``` |
| 57 | + |
| 58 | + d. Set appropriate parameters: |
| 59 | + |
| 60 | + ```powershell |
| 61 | + $resourceGroup="<your resource group>" |
| 62 | + $serverName = "<your server name>" |
| 63 | + $location = "<your location>" |
| 64 | + $localUser = "Administrator" # Use a local admin account for testing |
| 65 | + ``` |
| 66 | + |
| 67 | + e. Install the `OpenSSH` Arc Extension: |
| 68 | + |
| 69 | + ```powershell |
| 70 | + az connectedmachine extension create --name WindowsOpenSSH |
| 71 | + --type WindowsOpenSSH --publisher Microsoft.Azure.OpenSSH --type-handler-version 3.0.1.0 --machine-name $serverName --resource-group $resourceGroup |
| 72 | + ``` |
| 73 | + |
| 74 | + Here's a sample output: |
| 75 | + |
| 76 | + ```powershell |
| 77 | + 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 |
| 78 | + { |
| 79 | + "id": "/subscriptions/<SubscriptionName>/resourceGroups/<ResourceGroupName>/providers/<ProviderName>/machines/<MachineName>/extensions/WindowsOpenSSH", |
| 80 | + "location": "westeurope", |
| 81 | + "name": "WindowsOpenSSH", |
| 82 | + "properties": { |
| 83 | + "autoUpgradeMinorVersion": false, |
| 84 | + "enableAutomaticUpgrade": true, |
| 85 | + "instanceView": { |
| 86 | + "name": "WindowsOpenSSH", |
| 87 | + "status": { |
| 88 | + "code": "0", |
| 89 | + "level": "Information", |
| 90 | + "message": "Extension Message: OpenSSH Successfully enabled" |
| 91 | + }, |
| 92 | + "type": "WindowsOpenSSH", |
| 93 | + "typeHandlerVersion": "3.0.1.0" |
| 94 | + }, |
| 95 | + "provisioningState": "Succeeded", |
| 96 | + "publisher": "Microsoft.Azure.OpenSSH", |
| 97 | + "type": "WindowsOpenSSH", |
| 98 | + "typeHandlerVersion": "3.0.1.0", |
| 99 | + }, |
| 100 | + "resourceGroup": "<ResourceGroupName>", |
| 101 | + "type": "Microsoft.HybridCompute/machines/extensions" |
| 102 | + } |
| 103 | + PS C:\Users\labadmin> |
| 104 | + ``` |
| 105 | + |
| 106 | + f. You can see `WindowsOpenSSH` Extension in the Azure portal Extensions list view. |
| 107 | + |
| 108 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/azure-portal-extensions-list-view-3.png" alt-text="Screenshot of Azure portal Extensions list view." lightbox="./media/connect-arc-vm-using-ssh/azure-portal-extensions-list-view-3.png"::: |
| 109 | + |
| 110 | +## Use SSH to connect to Azure Local |
| 111 | + |
| 112 | +> [!NOTE] |
| 113 | +> You may be asked to allow Arc SSH to set up port 22 for SSH. |
| 114 | +
|
| 115 | +Use the following steps to connect to Azure Local. |
| 116 | + |
| 117 | +1. Run the following command to launch Arc SSH and sign in to the server: |
| 118 | + |
| 119 | + ```powershell |
| 120 | + az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser |
| 121 | + ``` |
| 122 | + |
| 123 | + You're now connected to Azure Local over SSH: |
| 124 | + |
| 125 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/server-connection-6.png" alt-text="Screenshot of server connection over SSH." lightbox="./media/connect-arc-vm-using-ssh/server-connection-6.png"::: |
| 126 | + |
| 127 | +## Use RDP over SSH to connect to Azure Local |
| 128 | + |
| 129 | +1. To sign into Azure Local using RDP over SSH, run the following command with the RDP parameter: |
| 130 | + |
| 131 | + ```powershell |
| 132 | + az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser --rdp |
| 133 | + ``` |
| 134 | + |
| 135 | +1. Sign in to the local server for RDP over SSH. |
| 136 | + |
| 137 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/server-login-dialog-for-ssh-arc-connection-5.png" alt-text="Screenshot of server sign-in dialog to connect to Windows Server over SSH." lightbox="./media/connect-arc-vm-using-ssh/server-login-dialog-for-ssh-arc-connection-5.png"::: |
| 138 | + |
| 139 | +1. Sign in to authenticate for RDP. |
| 140 | + |
| 141 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/rdp-login-dialog-for-ssh-arc-connection-6.png" alt-text="Screenshot of the RDP server sign-in dialog to connect to Windows Server over SSH." lightbox="./media/connect-arc-vm-using-ssh/rdp-login-dialog-for-ssh-arc-connection-6.png"::: |
| 142 | + |
| 143 | +1. You can see the desktop for the remote desktop connection. |
| 144 | + |
| 145 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/rdp-desktop-for-ssh-arc-connection-9.png" alt-text="Screenshot of the RDP desktop to connect to Windows Server over SSH." lightbox="./media/connect-arc-vm-using-ssh/rdp-desktop-for-ssh-arc-connection-9.png"::: |
| 146 | + |
| 147 | + You set up an RDP tunnel over SSH into your Azure Local using Azure CLI without any VPN or open ports at your firewall. |
| 148 | + |
| 149 | +## Next steps |
| 150 | + |
| 151 | +- [What is Azure Arc VM management?](azure-arc-vm-management-overview.md) |
0 commit comments