0
0
Azurecloud~10 mins

SSH and RDP access in Azure - Interactive Code Practice

Choose your learning style9 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.