How can i login to VM using Azure Bastion Host Other than Azure portal web based SSH?

Viewed 1660

I have created Azure Baston Host and VM in my Azure Subscription, I am able to SSH to my VM from Azure Portal by giving username and password, I am looking for alternate SSH method like CLI SSH.

I don't want to use Browser based SSH from Azure Portal, Please let me know any method to SSH to VM through Bastion Host from CLI.

2 Answers

That does not seem valid with Azure Bastion involved as far as I understand your requirement.

Azure Bastion, by design, is a service that's meant to provide RDP/SSH connectivity to your VMs directly from the Azure portal over TLS. It is architected as a PaaS service and is fully managed by the platform itself.

Here is how an Azure Bastion deployment looks like: Azure Bastion Architecture

As depicted above, the Bastion host is deployed in a VNet and the user connects to the Azure portal using any HTML5 browser.

If this does not fit your use case, you might have to consider building your own jumpbox and custom-configure your NSGs to harden security.

Azure Bastion now offers support for connecting to target VMs in Azure using a native RDP or SSH client on your Windows workstation.

Native client support is not yet available for use from your local Linux workstation.

More info here: https://docs.microsoft.com/en-us/azure/bastion/connect-native-client-windows

az login
az account set --subscription "<subscription ID>"

az network bastion ssh \
  --name "<BastionName>" \
  --resource-group "<ResourceGroupName>" \
  --target-resource-id "<VMResourceId>" \
  --auth-type "ssh-key" \
  --username "<Username>" \
  --ssh-key "<Filepath>"
Related