Azure Bastion: no more public RDP and SSH
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Day-to-day operations
-
Phase 3: Enterprise architecture
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Azure Bastion lets you open RDP and SSH sessions to your VMs through Azure itself, so the VMs don’t need a public IP and you never open port 3389 or 22 to the internet. We set it up first in Phase 2 because almost every maintenance job starts with “log in to the server”.
Open RDP and SSH ports are still one of the most common ways attackers get into servers. Bastion shuts those doors, and for lab and dev work its Developer SKU costs nothing.
You’ll start with the Developer SKU and run into its limits, then build a Standard Bastion with a proper NSG and connect from your own terminal.
| Time | You need | Cost | By the end you can |
|---|---|---|---|
| About 60 minutes, including two 10-minute Bastion deployments | vnet-saat, web01 and win01, the CLI | Part 1 costs nothing. Part 2 is about 35 US cents if you delete the Standard Bastion within an hour | Connect to private VMs through Bastion, pick the right SKU, and fix a Bastion subnet NSG |
What it is, in one line
Azure Bastion is a managed jump server that carries RDP and SSH to your private VMs over HTTPS.
In Simple Words
The reception desk in an office tower
Without Bastion, every office in the tower has its own door onto the street, and anyone passing by can walk up and try the lock. With Bastion those street doors are bricked up: visitors go to a single reception desk, show their ID, and a guard walks them to the office they’re allowed into.
The no-cost Developer SKU is like one receptionist who can only take a single visitor up at a time. The bigger SKUs bring more guards, let you drive in with your own car, and can even record each visit.
Engineer's View
Bastion SKUs and what they need
| Feature | Developer | Basic | Standard | Premium |
|---|---|---|---|---|
| Price (Central India) | No cost | USD 0.19/h | USD 0.29/h | USD 0.45/h |
| AzureBastionSubnet (/26) | No | Yes | Yes | Yes |
| Public IP | No | Yes | Yes | No (private-only option) |
| Concurrent sessions | One VM at a time | Yes | Yes | Yes |
| VNet peering | No | Yes | Yes | Yes |
| Native client (az network bastion rdp, tunnel) | No | No | Yes | Yes |
| Session recording | No | No | No | Yes |
- How it connects: your browser or the CLI talks to Bastion over HTTPS on 443, and Bastion then opens RDP or SSH to the VM’s private IP from inside the VNet. With the dedicated SKUs, that connection comes from the AzureBastionSubnet addresses.
- VM side: the VM’s NSG has to allow 3389 or 22 from wherever Bastion connects from. For the dedicated SKUs, the default AllowVnetInBound rule normally takes care of that.
- NSG on AzureBastionSubnet: you don’t have to add one, but if you do, it must carry Microsoft’s required inbound and outbound rules or Azure won’t accept it.
- Billing: the dedicated SKUs charge by the hour from the moment you deploy them, even if nobody ever connects. Developer runs on a shared pool and is only offered in some regions, Central India and South India among them.
- Access control: to connect, a user needs Reader on the VM, on its NIC and on the Bastion resource, plus a working login on the OS itself.
How it works, step by step
What happens when you click Connect, Bastion on web01:
- The portal opens an HTTPS session to Bastion in your browser.
- Bastion checks that you’re allowed to read the VM and its NIC.
- From inside the VNet, it opens SSH to web01’s private IP, 10.30.1.4.
- You enter the username and the key or password, and the VM checks them the normal way.
- The terminal streams back into your browser tab, and at no point is a port on web01 open to the internet.
If you’re on Standard or Premium and native client support is turned on, you can do the same from the CLI on your laptop: az network bastion ssh for Linux, az network bastion rdp for Windows, and az network bastion tunnel when you want to forward any port.
Most companies run one dedicated Bastion in a hub VNet and let it serve the VMs in every peered spoke (you’ll build that in Lesson 46).
Hands-on lab: Azure Bastion Developer and Standard
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Tell the CLI it may install the Bastion extension on its own, and start both VMs:
az config set extension.use_dynamic_install=yes_without_prompt
az vm start --resource-group rg-saat-vms --name web01
az vm start --resource-group rg-saat-vms --name win01Part 1: Bastion Developer (no cost)
1Create a Developer Bastion
Run this. It finishes in seconds, not minutes:
az network bastion create --resource-group rg-saat-core --name bas-saat-dev --sku Developer --vnet-name vnet-saat --location centralindia --tags course=saatvedha-azure lesson=27 keep=true -o none
az network bastion show --resource-group rg-saat-core --name bas-saat-dev --query "{name:name, sku:sku.name, state:provisioningState}" -o tableYou should see this:
Name Sku State
------------ --------- ---------
bas-saat-dev Developer Succeeded2SSH to web01 from the portal
In the portal, open web01 and go to Connect, then Bastion. Pick the Authentication type “SSH Private Key from Local File”, enter azureuser as the username, choose your key file from C:\Users\<you>\.ssh\id_rsa and click Connect.
In the browser terminal, run:
hostname; ip -4 -br addr show eth0You should see something like this:
web01
eth0 UP 10.30.1.4/24
3RDP to win01 from the portal
Close the web01 tab first, because Developer only lets you into one VM at a time. Then open win01, go to Connect, then Bastion, and sign in with the admin name and password you set in Lesson 16. Server Core opens straight into a command prompt, so type hostname.

Part 2: Bastion Standard with native client (paid, about 35 US cents)
4Create AzureBastionSubnet and its NSG
The subnet has to be called exactly AzureBastionSubnet. Create the NSG with Microsoft’s required rules first and then attach it:
az network vnet subnet create --resource-group rg-saat-core --vnet-name vnet-saat --name AzureBastionSubnet --address-prefixes 10.30.250.0/26 -o none
$rules = @(
@('AllowHttpsInbound', 100, 'Inbound', 'Internet', '*', '443'),
@('AllowGatewayManagerInbound', 110, 'Inbound', 'GatewayManager', '*', '443'),
@('AllowAzureLoadBalancerInbound', 120, 'Inbound', 'AzureLoadBalancer', '*', '443'),
@('AllowBastionHostCommunication', 130, 'Inbound', 'VirtualNetwork', 'VirtualNetwork', '8080 5701'),
@('AllowSshRdpOutbound', 100, 'Outbound', '*', 'VirtualNetwork', '22 3389'),
@('AllowAzureCloudOutbound', 110, 'Outbound', '*', 'AzureCloud', '443'),
@('AllowBastionCommunication', 120, 'Outbound', 'VirtualNetwork', 'VirtualNetwork', '8080 5701'),
@('AllowHttpOutbound', 130, 'Outbound', '*', 'Internet', '80')
)
az network nsg create --resource-group rg-saat-core --name nsg-saat-bastion --tags course=saatvedha-azure lesson=27 keep=true -o none
foreach ($x in $rules) {
az network nsg rule create --resource-group rg-saat-core --nsg-name nsg-saat-bastion --name $x[0] --priority $x[1] --direction $x[2] --source-address-prefixes $x[3] --destination-address-prefixes $x[4] --destination-port-ranges ($x[5] -split ' ') --protocol '*' --access Allow -o none
}
az network vnet subnet update --resource-group rg-saat-core --vnet-name vnet-saat --name AzureBastionSubnet --network-security-group nsg-saat-bastion -o none
az network nsg rule list --resource-group rg-saat-core --nsg-name nsg-saat-bastion --query "length([])"You should see this:
85Swap the Developer Bastion for Standard
A VNet can only have one Bastion, so the Developer one has to go first. The Standard deployment then takes around 10 minutes:
az network bastion delete --resource-group rg-saat-core --name bas-saat-dev
az network public-ip create --resource-group rg-saat-core --name pip-saat-bastion --sku Standard --location centralindia --tags course=saatvedha-azure lesson=27 -o none
az network bastion create --resource-group rg-saat-core --name bas-saat --sku Standard --vnet-name vnet-saat --public-ip-address pip-saat-bastion --enable-tunneling true --location centralindia --tags course=saatvedha-azure lesson=27 -o none
az network bastion show --resource-group rg-saat-core --name bas-saat --query "{name:name, sku:sku.name, tunneling:enableTunneling, state:provisioningState}" -o tableYou should see this:
Name Sku Tunneling State
-------- -------- ----------- ---------
bas-saat Standard True Succeeded6SSH from your own terminal
Run this, and then type the commands inside the session:
$web01 = az vm show --resource-group rg-saat-vms --name web01 --query id -o tsv
az network bastion ssh --name bas-saat --resource-group rg-saat-core --target-resource-id $web01 --auth-type ssh-key --username azureuser --ssh-key $HOME\.ssh\id_rsaInside the session you should see something like this:
azureuser@web01:~$ hostname
web01
azureuser@web01:~$ exit
✅ Checkpoint: You reached web01 and win01 with no public IP on either, first from the portal and then from your own terminal.
Break It, Then Fix It
You’ll usually hit both of these in the first week a team starts using Bastion.
1Break it: native RDP with the wrong SKU
Run this before step 5, while bas-saat-dev is the only Bastion you have. (Already past step 5? Read along.)
$win01 = az vm show --resource-group rg-saat-vms --name win01 --query id -o tsv
az network bastion rdp --name bas-saat-dev --resource-group rg-saat-core --target-resource-id $win01You’ll get this error:
Bastion Host SKU must be Standard or Premium and Native Client must be enabled.The CLI checks the Bastion before it even tries. Developer and Basic only work through the portal, and Standard only works once native client support (--enable-tunneling true) is switched on.
Fix it: for Developer, use the portal, or once you’ve done step 5, point the command at the Standard Bastion:
az network bastion rdp --name bas-saat --resource-group rg-saat-core --target-resource-id $win01Remote Desktop opens on your laptop and connects to win01 through Bastion.

2Break it: an NSG that blocks Bastion
A colleague wants things “tight”, so they create an NSG with no rules of their own and attach it to AzureBastionSubnet:
az network nsg create --resource-group rg-saat-core --name nsg-bastion-tight -o none
az network vnet subnet update --resource-group rg-saat-core --vnet-name vnet-saat --name AzureBastionSubnet --network-security-group nsg-bastion-tightYou’ll get an error like this:
(NetworkSecurityGroupNotCompliantForAzureBastionSubnet) Network security group nsg-bastion-tight does not have necessary rules for Azure Bastion Subnet AzureBastionSubnet.
Code: NetworkSecurityGroupNotCompliantForAzureBastionSubnetAzure won’t let an NSG on AzureBastionSubnet break the service. The default rules in an NSG don’t cover what Bastion needs, so you have to add the explicit inbound 443 rules and the outbound rules from step 4.
Fix it: keep the compliant NSG and delete the tight one. After that, clean up the paid parts and bring the Developer Bastion back:
az network nsg delete --resource-group rg-saat-core --name nsg-bastion-tight
az network bastion delete --resource-group rg-saat-core --name bas-saat
az network public-ip delete --resource-group rg-saat-core --name pip-saat-bastion
az network bastion create --resource-group rg-saat-core --name bas-saat-dev --sku Developer --vnet-name vnet-saat --location centralindia --tags course=saatvedha-azure lesson=27 keep=true -o none
az vm deallocate --resource-group rg-saat-vms --name web01
az vm deallocate --resource-group rg-saat-vms --name win01
az network bastion list --resource-group rg-saat-core --query "[].{name:name, sku:sku.name}" -o tableYou should see this:
Name Sku
------------ ---------
bas-saat-dev Developer
✅ Checkpoint: The Standard Bastion and its public IP are gone, bas-saat-dev is back for later lessons, and both VMs are deallocated.
Leave AzureBastionSubnet and nsg-saat-bastion where they are. They don’t cost anything, and Lesson 46 needs them.
This happened at work
The RDP port that was “only open for a day”
This was at a manufacturing company. A vendor had to make an urgent fix, so someone opened RDP to a Windows VM from the internet and planned to close it the next day. Nobody did. Six weeks later the monitoring team noticed the VM sending traffic to unknown addresses in the middle of the night.
When they pulled up the security log, there were over 200,000 failed sign-ins from bots and then one that worked, on a local account with a weak password. By then the attacker had put a crypto miner on the box and was trying to get into other servers in the VNet.
What they changed: all admin access now goes through Bastion Standard in the hub VNet, and an Azure Policy denies any NSG rule that allows 3389 or 22 from the internet. Vendors get time-limited access through Bastion with just-in-time approval (Lesson 28), and LAPS rotates the local admin passwords.
Common mistakes and troubleshooting
| Mistake | What you see | What to do |
|---|---|---|
| Subnet not named AzureBastionSubnet | Bastion create fails | Exact name, /26 or larger. |
| NSG on the Bastion subnet without required rules | NetworkSecurityGroupNotCompliantForAzureBastionSubnet | Add Microsoft’s inbound and outbound rules. |
| VM NSG denies 22/3389 from the VNet | Bastion connects, then times out | Allow the Bastion source in the VM’s NSG. |
| Native client on Basic or Developer | “SKU must be Standard or Premium” | Standard with tunneling, or use the portal. |
| Leaving a Standard Bastion in a lab | Hourly bill keeps running | Delete it, or use Developer. |
| Expecting Developer to reach peered VNets | Spoke VMs not listed | Use Basic or higher in the hub. |
| User has no Reader on the VM or NIC | Connect option greyed out | Grant Reader on VM, NIC and Bastion. |
Interview questions
Click any question to open it. They’re worded the way an interviewer would ask them, and under each one you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. What is Azure Bastion?
Why they ask this: To see if you know the basic idea.
How you might answer: It’s a managed service that gives you RDP and SSH to your VMs through Azure over HTTPS, so the VMs don’t need public IPs and you don’t open management ports to the internet.
2. What subnet does Azure Bastion need?
Why they ask this: It’s a setting people often get wrong.
How you might answer: For Basic, Standard and Premium you need a subnet called exactly AzureBastionSubnet, sized /26 or bigger. Developer doesn’t need one at all.
3. Why is Bastion safer than a public IP with RDP open?
Why they ask this: They want the security reasoning behind it.
How you might answer: There’s no management port on the internet, so bots have nothing to brute-force. You have to get through Azure sign-in and RBAC first, sessions can be logged, and on Premium they can be recorded too.
2–5 years experience
4. Users can open Bastion but the session times out. What do you check?
Why they ask this: It’s a troubleshooting path you’ll walk in real life.
How you might answer: I’d start with the VM’s NSG and the OS firewall, to make sure 3389 or 22 is allowed from the Bastion subnet. Then I’d check the VM is running and listening, look for UDRs that could send the return traffic somewhere else, and check the NSG on AzureBastionSubnet if there is one.
5. Which Bastion SKU would you choose for a company, and why?
Why they ask this: They want to hear you weigh cost against features.
How you might answer: For most companies I’d go with Standard in the hub VNet, because you get native client, tunneling, peered VNets and scaling. If they need session recording or a private-only deployment, then Premium. I’d keep Developer for dev and test.
6. How do you connect to a VM with Bastion from the command line?
Why they ask this: They’re checking native client knowledge.
How you might answer: The Bastion has to be Standard or Premium with native client support on. Then it’s az network bastion ssh for Linux, az network bastion rdp for Windows, or az network bastion tunnel if I need to forward a port for some other tool.
Senior level
7. How would you design admin access for 500 VMs across 20 VNets?
Why they ask this: They want to see how you’d design it.
How you might answer: I’d go hub-and-spoke, with one Standard or Premium Bastion in the hub peered to all the spokes. On top of that, Entra ID sign-in with PIM for admin roles, an Azure Policy that blocks public RDP and SSH, JIT where it’s needed, and the logs going into Log Analytics.
8. What are the risks of Bastion’s shareable links?
Why they ask this: They want to see if you can weigh a security trade-off.
How you might answer: Whoever has the link can get to the VM’s login screen without signing in to Azure. That’s handy for vendors, but the links should be short-lived, tracked and deleted afterwards, and the VM still needs strong credentials.
9. How would you audit who connected to which VM through Bastion?
Why they ask this: They’re checking whether you know where the logs live.
How you might answer: I’d send the Bastion diagnostic logs to Log Analytics and query the audit logs for the user, target VM, source IP and time. On Premium you also get session recordings in a storage account, so you can play a whole session back.
Quick quiz
Q1. Which Bastion SKU needs no AzureBastionSubnet?
- Developer
- Basic
- Standard
- Premium
Show answer
A — Developer uses a shared pool and no subnet.
Q2. What is the minimum size of AzureBastionSubnet?
- /29
- /27
- /26
- /24
Show answer
C — A /26 or larger is required.
Q3. Which SKUs support az network bastion rdp?
- All
- Developer and Basic
- Standard and Premium with native client on
- Premium only
Show answer
C — Native client needs Standard or Premium with tunneling.
Q4. An NSG with no custom rules is attached to AzureBastionSubnet. Result?
- Works
- NetworkSecurityGroupNotCompliantForAzureBastionSubnet
- Bastion upgrades
- VMs get public IPs
Show answer
B — Bastion subnet NSGs need Microsoft’s required rules.
Q5. How is a Standard Bastion billed?
- Per session
- Per hour from deployment
- Per GB only
- It costs nothing
Show answer
B — Hourly while it exists, used or not.
Quick recap
From here on you can reach any VM in this course without opening a single port to the internet.
- Bastion brings RDP and SSH to private VMs over HTTPS.
- Developer: no cost, one VM at a time, portal only, no peering.
- Basic and up need AzureBastionSubnet (/26) and a public IP.
- Native client needs Standard or Premium with tunneling.
- A Bastion subnet NSG must carry Microsoft’s required rules.
Next lesson
Lesson 28: Just-in-time VM access with Defender for Cloud → Next, you open management ports only when someone asks, for a few hours and from one IP.
Further reading: Azure Bastion
Want to go deeper into Azure Bastion? Microsoft’s Bastion SKU comparison and Working with NSG access and Azure Bastion are good next reads, and the full plan for this course is on the Azure Cloud Administration course page.
