Skip to content

Instantly share code, notes, and snippets.

@jreypo
Created April 12, 2023 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jreypo/babf475d1a2b678b7dc1347f6dc78f9f to your computer and use it in GitHub Desktop.
Save jreypo/babf475d1a2b678b7dc1347f6dc78f9f to your computer and use it in GitHub Desktop.
Script to open an tunnel to Azure Bastion and use Remote Desktop to acess a VM in Azure
#!/bin/bash
#
# Azure Bastion tunnel script by @jreypo
#
echo -n "Enter resource group name: "
read rg
echo -n "Enter Bastion name: "
read bastion
echo -n "Enter virtual machine name: "
read vmname
echo -n "Enter remote resource port: "
read resourceport
echo -n "Enter local port: "
read port
vmid=$(az vm show --resource-group $rg --name $vmname --query id --output tsv)
az network bastion tunnel --resource-group $rg --target-resource-id $vmid --resource-port $resourceport --port $port --name $bastion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment