azuresshazure-bastion

ssh into Azure VM from local MacOS terminal using Bastion tunnel


I have a UAT Bastion-enabled Management VM in Azure.

I have already copied my public ssh-key into the machine.

I am able to access the machine using web-browser. However, I wish to connect via terminal due to familiary and ease-of-use.

I wish to connect to the VM from local terminal using the below command -

az network bastion ssh --name MyBastionHost --resource-group MyResourceGroup \
--target-resource-id vmResourceId --auth-type ssh-key \
--username xyz --ssh-key ~/.ssh/id_rsa

This gives me a 'bastion' is misspelled or not recognized by the system. error on local.

az cli version details -

  "azure-cli": "2.67.0",
  "azure-cli-core": "2.67.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Local machine OS - MacOS

Remote VM - Ubuntu 22.04

Is bastion support disabled for this tenant ? Do I need to check any logs to find out ?


Solution

  • This gives me a 'bastion' is misspelled or not recognized by the system. error on local.

    The error you are encountering is due to the Bastion extension not being installed on your laptop

    To resolve this, run the command below to install the Bastion service

    az extension update --name bastion
    

    Once the extension is installed, make sure to verify the Bastion installation.

    az extension show --name bastion
    

    enter image description here

    Below are the prerequisites to run the az network bastion ssh.Follow the MS Doc for more details

    enter image description here

    Bastion supports the Standard and Premium tiers, along with Native client support option enabled. For more details, refer to the MS DOC.

    enter image description here

    After configuring all the settings, I am able to connect to the Linux VM using az network bastion ssh

    enter image description here