Created
April 12, 2023 14:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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