Exposing SSH to the internet is one of the most common ways Linux servers get attacked. A public IP address combined with an open port 22 invites constant brute-force login attempts, credential stuffing, and vulnerability scanning, even when your passwords are strong and your keys are well managed. An azure bastion linux vm setup removes that exposure entirely: you connect through a managed jump host inside your own virtual network, and your virtual machine never needs a public IP address at all.

Azure Bastion is a fully managed platform-as-a-service jump host that you deploy inside your Azure virtual network. Instead of opening SSH to the world, you open a browser session in the Azure portal, authenticate with your Azure credentials, and Bastion brokers an SSH connection to the private IP address of your VM. The traffic stays inside Azure, your VM stays off the public internet, and you no longer need to maintain a separate hardened bastion server of your own.
Prerequisites
Before you deploy Bastion, you need an Azure subscription, a resource group, and a virtual network with at least one Linux virtual machine that has a private IP address. This azure bastion linux vm guide assumes your VM has no public IP address, and in fact the whole point is that it should not have one. You also need an address range free inside your virtual network for the dedicated Bastion subnet, plus either a password or an SSH private key for a user account on the VM. The Azure CLI is useful for the command-line steps, but the portal alone is enough to get started.
Why Public IPs and Open SSH Ports Are Risky
Every SSH server exposed to the internet is found within minutes by automated scanners. They try common usernames, leaked passwords, and known exploits around the clock. Key-based authentication and fail2ban reduce the risk, but they do not remove it: the attack surface is still reachable, and a single misconfiguration, such as accidentally allowing password authentication, can turn background noise into a breach. Restricting the source IP address in a network security group helps, but your home or office IP address changes, and every exception you add is another hole to maintain.
Removing the public IP address changes the equation. If there is no public route to the VM, internet scanners cannot reach its SSH port at all. That is the security model Bastion provides, and it pairs well with other hardening steps, such as disabling password authentication and keeping the operating system patched. For a refresher on building a secure VM in the first place, see this guide to hardening a new Azure Linux virtual machine.
How an Azure Bastion Linux VM Session Works
When you connect through Bastion, your browser talks over TLS on port 443 to the Bastion host in your virtual network. Bastion then opens an SSH session from inside the network to the private IP address of your target VM on port 22. Your SSH credentials or private key are passed through this session, but the VM itself is never directly reachable from the internet. Because the connection is brokered by Azure, you do not need a VPN, a public IP, or an agent installed on the VM.
Bastion also simplifies access management. Portal access is governed by Azure role-based access control, so you can grant a team member permission to connect to a VM without sharing SSH keys or opening firewall rules for them. When someone leaves the team, removing their Azure access removes their Bastion access too. Session logs in Azure provide an audit trail of who connected and when, which is far easier to review than scattered SSH logs on individual servers.
Deploying Your Azure Bastion Linux VM Access
Bastion is deployed into a dedicated subnet that must be named exactly AzureBastionSubnet. The subnet must be at least a /26, which gives 64 addresses, because Bastion scales by adding instances inside that subnet. A smaller subnet, such as a /27 or /28, will fail deployment, and this is the single most common setup mistake. Plan the address space before you deploy, because you cannot easily resize a subnet that already contains resources.
There are two main SKUs to choose between. Basic covers browser-based SSH and RDP and is the cheapest way to remove public IPs. Standard adds native client support, so you can connect from your local terminal, plus IP-based connection and shareable links for cross-tenant access. Session recording is a Premium SKU feature and is worth considering if you need an audit record of exactly what happened during a session. For most Linux administration, Standard is the sweet spot, while Basic is fine if every admin is happy working in the browser.
To deploy with the Azure CLI, first create the dedicated subnet, then a Standard static public IP address for Bastion itself, then the Bastion host. Note that Bastion itself uses a public IP address for its own frontend, but your VMs still have none:
az network vnet subnet create \
--resource-group my-rg \
--vnet-name my-vnet \
--name AzureBastionSubnet \
--address-prefixes 10.0.2.0/26
az network public-ip create \
--resource-group my-rg \
--name my-bastion-pip \
--sku Standard \
--allocation-method Static
az network bastion create \
--name my-bastion \
--public-ip-address my-bastion-pip \
--resource-group my-rg \
--vnet-name my-vnet \
--location eastus \
--sku Standard
Deployment takes several minutes. You can follow the same steps in the portal by searching for Bastions, choosing your virtual network, and letting Azure create the subnet and public IP address for you. Either way, verify afterwards that the Bastion host shows a succeeded provisioning state before you try to connect.
Connecting to a Linux VM Through the Portal
Connecting is straightforward once Bastion is deployed, and an azure bastion linux vm connection needs no public IP on the VM at all. Open your virtual machine in the Azure portal, choose Connect, then Bastion. Enter the username and either the password or the SSH private key for the VM account, confirm port 22, and click Connect. A browser-based terminal opens in a new tab, and you are logged into the VM over SSH without ever seeing a public IP address.
If you authenticate with an SSH key, paste the private key content into the portal field or upload the key file when prompted. Keep in mind that pasting a private key into a browser session is a trade-off: it is convenient, but for day-to-day work the native client described below is better, because your private key never leaves your own machine. For one-off access, such as an emergency fix from a borrowed computer, the portal method is ideal.
Once connected, the session behaves like a normal SSH terminal. You can run administrative commands, edit configuration files, and restart services. The browser terminal supports text copy and paste, although file transfer is limited in the browser session. If you need to copy files, use the native client tunnel or transfer files through another private channel, such as storage attached to the same virtual network. For related storage concepts, this guide to Azure Blob storage tiers explains how to pick the right tier for backups and archives.
Native Client Support on the Standard SKU
With the Standard SKU, you can connect from your local terminal instead of the browser, which gives you a normal SSH client with port forwarding and file transfer. This is the recommended workflow for daily administration. The command looks like this:
az network bastion ssh \
--name my-bastion \
--resource-group my-rg \
--target-resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.Compute/virtualMachines/my-vm \
--auth-type ssh-key \
--username azureuser \
--ssh-key ~/.ssh/id_rsa
If your Azure CLI prompts for the bastion extension, install it first with az extension add --name bastion and retry. The native client also enables file transfer through the tunnel, so you can use scp over the Bastion connection to move configuration files and backups without opening any additional ports. This combination, private VM plus native client, is the closest thing to having a traditional jump host, without the burden of patching and securing one yourself.
Network Security Groups and Cost Notes
Bastion needs specific traffic to function, so do not lock down the AzureBastionSubnet network security group aggressively in an azure bastion linux vm deployment. In particular, the subnet must allow inbound traffic from the GatewayManager and AzureLoadBalancer service tags and outbound traffic to the virtual network on ports 22 and 3389. A common failure is applying a “deny all inbound” rule to the Bastion subnet and then wondering why connections time out. If you must use a custom network security group on the subnet, follow the official Azure Bastion documentation for the required rules rather than guessing.
On cost, Bastion is billed hourly for each deployed instance, plus data transfer, for as long as the host exists. There is no stop button that pauses billing, so a Bastion host you deploy and forget will keep charging. If you only need Bastion occasionally, consider whether a small deployment used for a maintenance window and then deleted is cheaper than a permanently running host. For production environments with regular administrative access, the hourly cost is usually small compared with the risk and maintenance cost of a self-managed jump host.
Troubleshooting
If deployment fails, check the subnet first: most azure bastion linux vm deployment failures come from the subnet, not from the VM. The name must be exactly AzureBastionSubnet, and the prefix must be /26 or larger. If the address space overlaps an existing subnet or the range is already in use, deployment will fail with an address-space error. Free up or re-plan the range and try again.
If Bastion deploys but connections fail or time out, check the network security group on the Bastion subnet and on the VM subnet. A rule blocking the GatewayManager service tag, or blocking outbound traffic from Bastion to the VM on port 22, will break the session. Also confirm the VM is running and that its SSH service is listening on port 22. Bastion does not require an agent on the VM, but a stopped VM or a firewall rule inside the guest operating system, such as an iptables rule dropping port 22, will still block you. Check the guest firewall with the serial console if you cannot connect any other way.
Authentication failures usually mean the wrong username, a mistyped password, or a key in the wrong format. The portal expects an OpenSSH private key, not a PuTTY .ppk file. If you use the native client, confirm the key path and that the matching public key is in the VM user’s authorized_keys file. Finally, remember the copy-and-paste limits: the browser session supports text only, so large pastes can be slow and file uploads are not supported there. Switch to the native client when you need to move files.
Conclusion
An azure bastion linux vm setup is one of the simplest high-value security improvements you can make to an Azure environment. You remove public IP addresses and open SSH ports, keep administration inside your virtual network, and gain Azure-managed access control and auditing. Once your azure bastion linux vm access is working, keep your network security groups aligned with the documented requirements. Your VMs stay private, your admins stay productive, and internet scanners find nothing to attack.