PowerShell remoting to Azure Arc-enabled servers

SSH for Arc-enabled servers enables SSH based connections to Arc-enabled servers without requiring a public IP address or additional open ports. PowerShell remoting over SSH is available for Windows and Linux machines.

Prerequisites

To leverage PowerShell remoting over SSH access to Azure Arc-enabled servers, ensure the following:

  • Ensure the requirements for SSH access to Azure Arc-enabled servers are met.
  • Ensure the requirements for PowerShell remoting over SSH are met.
  • The Azure PowerShell module or the Azure CLI extension for connecting to Arc machines is present on the client machine.

How to connect via PowerShell remoting

Follow the below steps to connect via PowerShell remoting to an Arc-enabled server.

az ssh config --resource-group <myRG> --name <myMachine> --local-user <localUser> --resource-type Microsoft.HybridCompute --file <SSH config file>

Find newly created entry in the SSH config file

Open the created or modified SSH config file. The entry should have a similar format to the following.

Host <myRG>-<myMachine>-<localUser>
	HostName <myMachine>
	User <localUser>
	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"

Leveraging the -Options parameter

Levering the options parameter allows you to specify a hashtable of SSH options used when connecting to a remote SSH-based session. Create the hashtable by following the below format. Be mindful of the locations of quotation marks.

$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"'}

Next leverage the options hashtable in a PowerShell remoting command.

New-PSSession -HostName <myMachine> -UserName <localUser> -Options $options

Next steps