|
| 1 | +--- |
| 2 | +title: SSH access to Azure Arc-enabled servers with PowerShell remoting |
| 3 | +description: Use PowerShell remoting over SSH to access and manage Azure Arc-enabled servers. |
| 4 | +ms.date: 04/08/2024 |
| 5 | +ms.topic: conceptual |
| 6 | +ms.custom: references_regions |
| 7 | +--- |
| 8 | + |
| 9 | +# PowerShell remoting to Azure Arc-enabled servers |
| 10 | +SSH for Arc-enabled servers enables SSH based connections to Arc-enabled servers without requiring a public IP address or additional open ports. |
| 11 | +[PowerShell remoting over SSH](/powershell/scripting/security/remoting/ssh-remoting-in-powershell) is available for Windows and Linux machines. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | +To leverage PowerShell remoting over SSH access to Azure Arc-enabled servers, ensure the following: |
| 15 | + - Ensure the requirements for SSH access to Azure Arc-enabled servers are met. |
| 16 | + - Ensure the requirements for PowerShell remoting over SSH are met. |
| 17 | + - The Azure PowerShell module or the Azure CLI extension for connecting to Arc machines is present on the client machine. |
| 18 | + |
| 19 | +## How to connect via PowerShell remoting |
| 20 | +Follow the below steps to connect via PowerShell remoting to an Arc-enabled server. |
| 21 | + |
| 22 | +#### [Generate a SSH config file with Azure CLI:](#tab/azure-cli) |
| 23 | +```bash |
| 24 | +az ssh config --resource-group <myRG> --name <myMachine> --local-user <localUser> --resource-type Microsoft.HybridCompute --file <SSH config file> |
| 25 | +``` |
| 26 | + |
| 27 | +#### [Generate a SSH config file with Azure PowerShell:](#tab/azure-powershell) |
| 28 | + ```powershell |
| 29 | +Export-AzSshConfig -ResourceGroupName <myRG> -Name <myMachine> -LocalUser <localUser> -ResourceType Microsoft.HybridCompute/machines -ConfigFilePath <SSH config file> |
| 30 | +``` |
| 31 | + --- |
| 32 | + |
| 33 | +#### Find newly created entry in the SSH config file |
| 34 | +Open the created or modified SSH config file. The entry should have a similar format to the following. |
| 35 | +```powershell |
| 36 | +Host <myRG>-<myMachine>-<localUser> |
| 37 | + HostName <myMachine> |
| 38 | + User <localUser> |
| 39 | + ProxyCommand "<path to proxy>\.clientsshproxy\sshProxy_windows_amd64_1_3_022941.exe" -r "<path to relay info>\az_ssh_config\<myRG>-<myMachine>\<myRG>-<myMachine>-relay_info" |
| 40 | +``` |
| 41 | +#### Leveraging the -Options parameter |
| 42 | +Levering the [options](/powershell/module/microsoft.powershell.core/new-pssession#-options) parameter allows you to specify a hashtable of SSH options used when connecting to a remote SSH-based session. |
| 43 | +Create the hashtable by following the below format. Be mindful of the locations of quotation marks. |
| 44 | +```powershell |
| 45 | +$options = @{ProxyCommand = '"<path to proxy>\.clientsshproxy\sshProxy_windows_amd64_1_3_022941.exe -r <path to relay info>\az_ssh_config\<myRG>-<myMachine>\<myRG>-<myMachine>-relay_info"'} |
| 46 | +``` |
| 47 | +Next leverage the options hashtable in a PowerShell remoting command. |
| 48 | +```powershell |
| 49 | +New-PSSession -HostName <myMachine> -UserName <localUser> -Options $options |
| 50 | +``` |
| 51 | + |
| 52 | +## Next steps |
| 53 | + |
| 54 | +- Learn about [OpenSSH for Windows](/windows-server/administration/openssh/openssh_overview) |
| 55 | +- Learn about troubleshooting [SSH access to Azure Arc-enabled servers](ssh-arc-troubleshoot.md). |
| 56 | +- Learn about troubleshooting [agent connection issues](troubleshoot-agent-onboard.md). |
0 commit comments