|
| 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/06/2025 |
| 9 | +--- |
| 10 | + |
| 11 | +# Connect to an Arc VM on Azure Local using SSH |
| 12 | + |
| 13 | +[!INCLUDE [hci-applies-to-23h2](../includes/hci-applies-to-23h2.md)] |
| 14 | + |
| 15 | +This article uses an example to connect to an Azure Arc VM on Azure Local using Secure Shell (SSH). The example enables the OpenSSH Server via Arc Extension, using Azure CLI. This can also be done in Azure portal. |
| 16 | + |
| 17 | +## More about the SSH Server Extension |
| 18 | + |
| 19 | +You can open a Remote Desktop (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). |
| 20 | + |
| 21 | +The latest versions of Windows Server can also act as an SSH Server if you enable the OpenSSH Server Extension. For more information, see [OpenSSH for Windows overview](/windows-server/administration/OpenSSH/openssh-overview). |
| 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 | + :::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"::: |
| 32 | + |
| 33 | +1. Open a Windows PowerShell session as an administrator. |
| 34 | + |
| 35 | +1. Run the following cmdlets to ensure that the required Azure CLI Extensions are installed: |
| 36 | + |
| 37 | + ```powershell |
| 38 | + az extension add --upgrade --name connectedmachine |
| 39 | + az extension add --upgrade --name ssh |
| 40 | + ``` |
| 41 | + |
| 42 | +1. Sign in to Azure: |
| 43 | + |
| 44 | + ```powershell |
| 45 | + az login --use-device-code |
| 46 | + ``` |
| 47 | + |
| 48 | +1. Set appropriate parameters: |
| 49 | + |
| 50 | + ```powershell |
| 51 | + $resourceGroup="<your resource group>" |
| 52 | + $serverName = "<your server name>" |
| 53 | + $localUser = "Administrator" # Use a local admin account for testing |
| 54 | + ``` |
| 55 | + |
| 56 | +1. Install the `OpenSSH` Arc Extension: |
| 57 | + |
| 58 | + ```powershell |
| 59 | + 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 |
| 60 | + ``` |
| 61 | + |
| 62 | + Here's a sample output: |
| 63 | + |
| 64 | + ```powershell |
| 65 | + 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 |
| 66 | + { |
| 67 | + "id": "/subscriptions/<SubscriptionName>/resourceGroups/<ResourceGroupName>/providers/<ProviderName>/machines/<MachineName>/extensions/WindowsOpenSSH", |
| 68 | + "location": "westeurope", |
| 69 | + "name": "WindowsOpenSSH", |
| 70 | + "properties": { |
| 71 | + "autoUpgradeMinorVersion": false, |
| 72 | + "enableAutomaticUpgrade": true, |
| 73 | + "instanceView": { |
| 74 | + "name": "WindowsOpenSSH", |
| 75 | + "status": { |
| 76 | + "code": "0", |
| 77 | + "level": "Information", |
| 78 | + "message": "Extension Message: OpenSSH Successfully enabled" |
| 79 | + }, |
| 80 | + "type": "WindowsOpenSSH", |
| 81 | + "typeHandlerVersion": "3.0.1.0" |
| 82 | + }, |
| 83 | + "provisioningState": "Succeeded", |
| 84 | + "publisher": "Microsoft.Azure.OpenSSH", |
| 85 | + "type": "WindowsOpenSSH", |
| 86 | + "typeHandlerVersion": "3.0.1.0", |
| 87 | + }, |
| 88 | + "resourceGroup": "<ResourceGroupName>", |
| 89 | + "type": "Microsoft.HybridCompute/machines/extensions" |
| 90 | + } |
| 91 | + PS C:\Users\labadmin> |
| 92 | + ``` |
| 93 | + |
| 94 | +1. You can see `WindowsOpenSSH` Extension in the Azure portal Extensions list view. |
| 95 | + |
| 96 | + :::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"::: |
| 97 | + |
| 98 | +## Use SSH to connect to Azure Local |
| 99 | + |
| 100 | +> [!NOTE] |
| 101 | +> You may be asked to allow Arc SSH to set up port 22 for SSH. |
| 102 | +
|
| 103 | +Use the following steps to connect to Azure Local. |
| 104 | + |
| 105 | +1. Run the following command to launch Arc SSH and sign in to the server: |
| 106 | + |
| 107 | + ```powershell |
| 108 | + az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser |
| 109 | + ``` |
| 110 | + |
| 111 | + You're now connected to Azure Local over SSH: |
| 112 | + |
| 113 | + ```powershell |
| 114 | + Microsoft Windows [Version 10.0.20348.2655] |
| 115 | + (c) Microsoft Corporation. All rights reserved. |
| 116 | +
|
| 117 | + administrator@VMName C:\Users\Administrator> |
| 118 | + ``` |
| 119 | + |
| 120 | + You're now connected to Server Manager. |
| 121 | + |
| 122 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/server-manager-dashboard-7.png" alt-text="Screenshot of the Server Manager Dashboard for Windows Server over SSH." lightbox="./media/connect-arc-vm-using-ssh/server-manager-dashboard-7.png"::: |
| 123 | + |
| 124 | +## Use RDP to connect to Azure Local |
| 125 | + |
| 126 | +1. To sign into Azure Local using RDP, run the following command with the RDP parameter: |
| 127 | + |
| 128 | + ```powershell |
| 129 | + az ssh arc --resource-group $resourceGroup --name $serverName --local-user $localUser --rdp |
| 130 | + ``` |
| 131 | + |
| 132 | +1. Sign in to the local server for SSH. |
| 133 | + |
| 134 | + :::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"::: |
| 135 | + |
| 136 | +1. Sign in to authenticate for RDP. |
| 137 | + |
| 138 | + :::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"::: |
| 139 | + |
| 140 | +1. You're now connected to Server Manager. |
| 141 | + |
| 142 | + :::image type="content" source="./media/connect-arc-vm-using-ssh/server-manager-dashboard-7.png" alt-text="Screenshot of the Server Manager Dashboard for a Windows Server over SSH." lightbox="./media/connect-arc-vm-using-ssh/server-manager-dashboard-7.png"::: |
| 143 | + |
| 144 | +You have set up an RDP tunnel over SSH into your Azure Local using Azure CLI without any VPN or open ports at your firewall. |
| 145 | + |
| 146 | +## Next steps |
| 147 | + |
| 148 | +- [What is Azure Arc VM management?](azure-arc-vm-management-overview.md) |
0 commit comments