Bird
Raised Fist0
Azurecloud~10 mins

SSH and RDP access in Azure - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the port for SSH access in an Azure Network Security Group rule.

Azure
resource "azurerm_network_security_rule" "ssh_rule" {
  name                        = "SSH"
  priority                    = 1001
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "Tcp"
  source_port_range           = "*"
  destination_port_range      = "[1]"
  source_address_prefix       = "*"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.rg.name
  network_security_group_name = azurerm_network_security_group.nsg.name
}
Drag options to blanks, or click blank then click option'
A80
B3389
C22
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 3389 which is for RDP, not SSH.
Using HTTP or HTTPS ports like 80 or 443.
2fill in blank
medium

Complete the code to specify the port for RDP access in an Azure Network Security Group rule.

Azure
resource "azurerm_network_security_rule" "rdp_rule" {
  name                        = "RDP"
  priority                    = 1002
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "Tcp"
  source_port_range           = "*"
  destination_port_range      = "[1]"
  source_address_prefix       = "*"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.rg.name
  network_security_group_name = azurerm_network_security_group.nsg.name
}
Drag options to blanks, or click blank then click option'
A3389
B22
C443
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 22 which is for SSH, not RDP.
Using HTTP or HTTPS ports like 80 or 443.
3fill in blank
hard

Fix the error in the Azure VM SSH access configuration by completing the missing property.

Azure
resource "azurerm_linux_virtual_machine" "vm" {
  name                = "myLinuxVM"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  size                = "Standard_B1s"
  admin_username      = "azureuser"
  network_interface_ids = [azurerm_network_interface.nic.id]
  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }
  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "18.04-LTS"
    version   = "latest"
  }
  admin_ssh_key {
    username   = "azureuser"
    public_key = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"password123"
B"ssh-dss AAAAB3NzaC1kc3MAAACB...user@example.com"
C"mysecretkey"
D"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...user@example.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a password instead of a public key.
Using an invalid key format.
4fill in blank
hard

Fill both blanks to create a Network Security Group rule allowing SSH access only from a specific IP address.

Azure
resource "azurerm_network_security_rule" "ssh_restricted" {
  name                        = "SSHRestricted"
  priority                    = 1003
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "Tcp"
  source_port_range           = "*"
  destination_port_range      = "[1]"
  source_address_prefix       = "[2]"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.rg.name
  network_security_group_name = azurerm_network_security_group.nsg.name
}
Drag options to blanks, or click blank then click option'
A22
B3389
C203.0.113.5/32
D0.0.0.0/0
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 3389 which is for RDP.
Using 0.0.0.0/0 which allows all IPs.
5fill in blank
hard

Fill all three blanks to configure an Azure Windows VM with RDP access and a Network Security Group rule allowing RDP from any IP.

Azure
resource "azurerm_windows_virtual_machine" "winvm" {
  name                = [1]
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  size                = "Standard_B2ms"
  admin_username      = "adminuser"
  admin_password      = [2]
  network_interface_ids = [azurerm_network_interface.nic.id]
  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Premium_LRS"
  }
  source_image_reference {
    publisher = "MicrosoftWindowsServer"
    offer     = "WindowsServer"
    sku       = "2019-Datacenter"
    version   = "latest"
  }
}

resource "azurerm_network_security_rule" "rdp_allow" {
  name                        = "AllowRDP"
  priority                    = 1004
  direction                   = "Inbound"
  access                      = "Allow"
  protocol                    = "Tcp"
  source_port_range           = "*"
  destination_port_range      = "[3]"
  source_address_prefix       = "*"
  destination_address_prefix  = "*"
  resource_group_name         = azurerm_resource_group.rg.name
  network_security_group_name = azurerm_network_security_group.nsg.name
}
Drag options to blanks, or click blank then click option'
A"myWindowsVM"
B"P@ssw0rd1234"
C3389
D"adminuser"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the admin username as the password.
Using the wrong port for RDP.

Practice

(1/5)
1. Which port does SSH use to connect securely to a Linux virtual machine in Azure?
easy
A. Port 3389
B. Port 22
C. Port 80
D. Port 443

Solution

  1. Step 1: Identify SSH default port

    SSH (Secure Shell) uses port 22 by default to connect securely to Linux machines.
  2. Step 2: Compare with other ports

    Port 3389 is used by RDP, port 80 is for HTTP, and port 443 is for HTTPS, so they are incorrect for SSH.
  3. Final Answer:

    Port 22 -> Option B
  4. Quick Check:

    SSH = Port 22 [OK]
Hint: SSH always uses port 22 for Linux access [OK]
Common Mistakes:
  • Confusing SSH port with RDP port
  • Using HTTP or HTTPS ports for SSH
  • Assuming SSH uses a random port
2. Which of the following is the correct syntax to open port 3389 for RDP access in an Azure Network Security Group (NSG)?
easy
A. Allow inbound TCP on port 3389
B. Allow inbound TCP on port 22
C. Allow outbound UDP on port 3389
D. Allow inbound UDP on port 22

Solution

  1. Step 1: Identify RDP port and protocol

    RDP uses TCP protocol on port 3389 for Windows remote desktop connections.
  2. Step 2: Match correct NSG rule syntax

    Allowing inbound TCP on port 3389 opens RDP access. Other options use wrong ports or protocols.
  3. Final Answer:

    Allow inbound TCP on port 3389 -> Option A
  4. Quick Check:

    RDP = TCP 3389 inbound [OK]
Hint: RDP always needs inbound TCP on port 3389 [OK]
Common Mistakes:
  • Using UDP instead of TCP
  • Opening wrong port 22 for RDP
  • Setting outbound instead of inbound rules
3. Given this Azure CLI command to open SSH access, what will it do?
az network nsg rule create --resource-group MyResourceGroup --nsg-name MyNSG --name AllowSSH --protocol Tcp --direction Inbound --priority 1000 --source-address-prefixes '*' --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges 22 --access Allow
medium
A. Allows inbound TCP traffic on port 22 from any source
B. Blocks inbound TCP traffic on port 22 from any source
C. Allows outbound TCP traffic on port 22 to any destination
D. Allows inbound UDP traffic on port 22 from any source

Solution

  1. Step 1: Analyze command parameters

    The command creates an NSG rule named AllowSSH allowing inbound TCP traffic on port 22 from any source to any destination.
  2. Step 2: Confirm traffic direction and protocol

    Direction is inbound, protocol is TCP, port is 22, and access is Allow, so it opens SSH access.
  3. Final Answer:

    Allows inbound TCP traffic on port 22 from any source -> Option A
  4. Quick Check:

    Inbound TCP 22 allowed = SSH access [OK]
Hint: Inbound TCP 22 with Allow opens SSH [OK]
Common Mistakes:
  • Confusing inbound with outbound
  • Using UDP instead of TCP
  • Misreading port number
4. You tried to connect to a Windows VM via RDP but the connection timed out. Which of these is the most likely cause based on NSG rules?
medium
A. NSG allows inbound TCP on port 3389
B. NSG allows inbound UDP on port 22
C. NSG blocks inbound TCP on port 3389
D. NSG allows outbound TCP on port 3389

Solution

  1. Step 1: Understand RDP connection requirements

    RDP requires inbound TCP access on port 3389 to allow remote desktop connections.
  2. Step 2: Identify blocking rule

    If NSG blocks inbound TCP on port 3389, the connection will time out because traffic is denied.
  3. Final Answer:

    NSG blocks inbound TCP on port 3389 -> Option C
  4. Quick Check:

    Blocked inbound TCP 3389 causes timeout [OK]
Hint: Blocked inbound TCP 3389 causes RDP timeout [OK]
Common Mistakes:
  • Confusing inbound with outbound rules
  • Using wrong port for RDP
  • Assuming UDP is needed for RDP
5. You want to secure SSH access to your Linux VM in Azure so only your office IP (203.0.113.5) can connect. Which NSG rule configuration is best?
hard
A. Allow inbound TCP on port 22 from source 0.0.0.0/0
B. Allow inbound TCP on port 3389 from source 203.0.113.5/32
C. Allow inbound UDP on port 22 from source 203.0.113.5/32
D. Allow inbound TCP on port 22 from source 203.0.113.5/32

Solution

  1. Step 1: Identify SSH port and protocol

    SSH uses TCP on port 22, so the rule must allow TCP on port 22.
  2. Step 2: Restrict source IP to office IP

    To secure access, restrict source to the office IP with /32 mask for a single IP.
  3. Step 3: Exclude incorrect options

    Allow inbound TCP on port 22 from source 0.0.0.0/0 allows all IPs (not secure), Allow inbound UDP on port 22 from source 203.0.113.5/32 uses UDP (wrong protocol), Allow inbound TCP on port 3389 from source 203.0.113.5/32 uses RDP port (wrong service).
  4. Final Answer:

    Allow inbound TCP on port 22 from source 203.0.113.5/32 -> Option D
  5. Quick Check:

    Restrict SSH TCP 22 to office IP [OK]
Hint: Restrict SSH port 22 TCP to your IP only [OK]
Common Mistakes:
  • Allowing all IPs instead of specific IP
  • Using UDP instead of TCP
  • Opening wrong port for SSH
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard