Secure VM Access with Network Security Groups
Create and configure a Network Security Group to enable SSH access to a VM. Apply your knowledge of NSGs and security rules to secure the subnet.

Lab overview
Network Security Groups (NSGs) are Azure's distributed, stateful packet filter. An NSG holds a prioritized list of inbound and outbound security rules, and each rule matches traffic on a 5-tuple: source, source port, destination, destination port, and protocol. Rules are evaluated in priority order, lowest number first, and the first match wins. Because the filter is stateful, allowing an inbound connection automatically permits the return traffic without a matching outbound rule.
An NSG can be attached to a subnet, to a network interface, or to both. Attaching it to a subnet applies it to every resource in that subnet, which makes the subnet the usual place to enforce a baseline access policy. Every NSG also ships with default rules that permit traffic inside the virtual network and from the Azure load balancer, then deny everything else arriving from the internet. That final deny is why a freshly deployed VM stays unreachable over SSH until you add an explicit allow rule.
By completing this Beginner challenge, you will be able to:
- Create a Network Security Group and associate it with a subnet
- Write an inbound security rule that permits SSH traffic on TCP port 22
- Scope a rule's source address to restrict who can reach the VM
- Confirm network reachability by opening an SSH session to the VM
Prerequisites
Before attempting this challenge, you should be comfortable with:
- Creating and managing Network Security Groups
- Understanding the 5-tuple (source, destination, port, protocol, action)
- Associating NSGs with subnets
- Basic SSH connectivity
Recommended Lab: Implement Network Security Groups (NSGs) and Application Security Groups (ASGs) in Azure
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.
More labs like this
Implement Network Security Groups (NSGs) and Application Security Groups (ASGs) in Azure
Secure Azure VMs using Network Security Groups and Application Security Groups. Create rules, control traffic flow, and implement least privilege access.
Azure Virtual Network Peering - Connect VNets for Secure Communication
Learn how to configure and test virtual network peering in Azure.
Implementing Secure VM Access with Azure Bastion
In this lab, you will learn how to implement secure VM access with Azure Bastion using Azure portal.
Related reading
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Enable SSH Access to the Development VM
2 automated checks
Skills validated
Not the lab you were looking for?
Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.