Skip to content

Commit d5acb83

Browse files
committed
Task 544784: Replace RDP/Remote Desktop with Bastion
- Changed VM-Spoke-01 from Windows to Ubuntu 22.04 LTS - Changed VM-Onprem from Windows to Ubuntu 22.04 LTS - Replaced password authentication with SSH keys (Azure-generated) - Updated network rule from AllowRDP to AllowSSH (port 22) - Replaced IIS with Nginx installation via Azure CLI - Added AzureBastionSubnet (10.5.3.0/26) to VNet-Hub - Deployed Azure Bastion with Developer SKU - Removed public inbound ports from VM-Onprem - Updated testing section to use Bastion SSH instead of RDP - Replaced web browser testing with curl commands - Removed screenshot reference for web page
1 parent 0f8ab37 commit d5acb83

1 file changed

Lines changed: 87 additions & 35 deletions

File tree

articles/firewall/tutorial-hybrid-portal.md

Lines changed: 87 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ First, add a network rule to allow web traffic:
187187
1. For **Destination Address**, enter **10.6.0.0/16**.
188188
1. For **Destination Ports**, enter **80**.
189189

190-
Now, add a rule to allow RDP traffic. On the second rule row, enter the following information:
190+
Now, add a rule to allow SSH traffic. On the second rule row, enter the following information:
191191

192-
1. For **Name**, enter **AllowRDP**.
192+
1. For **Name**, enter **AllowSSH**.
193193
1. For **Protocol**, select **TCP**.
194194
1. For **Source type**, select **IP address**.
195195
1. For **Source**, enter **192.168.0.0/24**.
196196
1. For **Destination type**, select **IP address**.
197197
1. For **Destination Address**, enter **10.6.0.0/16**.
198-
1. For **Destination Ports**, enter **3389**.
198+
1. For **Destination Ports**, enter **22**.
199199
1. Select **Add**.
200200

201201
## Create and connect the VPN gateways
@@ -376,17 +376,21 @@ Create the spoke workload and on-premises virtual machines, and place them in th
376376

377377
### Create the workload virtual machine
378378

379-
Create a virtual machine in the spoke virtual network that runs Internet Information Services (IIS) and has no public IP address:
379+
Create a virtual machine in the spoke virtual network that runs Nginx web server and has no public IP address:
380380

381381
1. On the Azure portal home page, select **Create a resource**.
382-
1. Under **Popular Marketplace products**, select **Windows Server 2019 Datacenter**.
382+
1. Under **Popular Marketplace products**, select **Ubuntu Server 22.04 LTS**.
383383
1. Enter these values for the virtual machine:
384384
- **Resource group**: Select **RG-fw-hybrid-test**.
385385
- **Virtual machine name**: Enter **VM-Spoke-01**.
386386
- **Region**: Select the same region that you used previously.
387-
- **User name**: Enter a username.
388-
- **Password**: Enter a password.
389-
1. For **Public inbound ports**, select **Allow selected ports**, and then select **HTTP (80)** and **RDP (3389)**.
387+
- **Image**: Ubuntu Server 22.04 LTS - x64 Gen2
388+
- **Size**: Standard_B2s
389+
- **Authentication type**: SSH public key
390+
- **Username**: **azureuser**
391+
- **SSH public key source**: Generate new key pair
392+
- **Key pair name**: **VM-Spoke-01_key**
393+
1. For **Public inbound ports**, select **None**.
390394
1. Select **Next: Disks**.
391395
1. Accept the defaults and select **Next: Networking**.
392396
1. For the virtual network, select **VNet-Spoke**. The subnet is **SN-Workload**.
@@ -395,67 +399,115 @@ Create a virtual machine in the spoke virtual network that runs Internet Informa
395399
1. Select **Next: Monitoring**.
396400
1. For **Boot diagnostics**, select **Disable**.
397401
1. Select **Review+Create**, review the settings on the summary page, and then select **Create**.
402+
1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **VM-Spoke-01_key.pem**.
398403

399-
### Install IIS
400-
401-
1. On the Azure portal, open Azure Cloud Shell and make sure that it's set to **PowerShell**.
402-
1. Run the following command to install IIS on the virtual machine, and change the location if necessary:
403-
404-
```azurepowershell-interactive
405-
Set-AzVMExtension `
406-
-ResourceGroupName RG-fw-hybrid-test `
407-
-ExtensionName IIS `
408-
-VMName VM-Spoke-01 `
409-
-Publisher Microsoft.Compute `
410-
-ExtensionType CustomScriptExtension `
411-
-TypeHandlerVersion 1.4 `
412-
-SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}' `
413-
-Location EastUS
404+
### Install Nginx
405+
406+
1. On the Azure portal, open Azure Cloud Shell and make sure that it's set to **Bash**.
407+
1. Run the following command to install Nginx on the virtual machine:
408+
409+
```azurecli-interactive
410+
az vm run-command invoke \
411+
--resource-group RG-fw-hybrid-test \
412+
--name VM-Spoke-01 \
413+
--command-id RunShellScript \
414+
--scripts "sudo apt-get update && sudo apt-get install -y nginx && echo '<h1>'$(hostname)'</h1>' | sudo tee /var/www/html/index.html"
414415
```
415416

416417
### Create the on-premises virtual machine
417418

418-
Create a virtual machine that you use to connect via remote access to the public IP address. From there, you can connect to the spoke server through the firewall.
419+
Create a virtual machine that you use to connect via Azure Bastion. From there, you can connect to the spoke server through the firewall.
419420

420421
1. On the Azure portal home page, select **Create a resource**.
421-
1. Under **Popular**, select **Windows Server 2019 Datacenter**.
422+
1. Under **Popular**, select **Ubuntu Server 22.04 LTS**.
422423
1. Enter these values for the virtual machine:
423424
- **Resource group**: Select **Existing**, and then select **RG-fw-hybrid-test**.
424425
- **Virtual machine name**: Enter **VM-Onprem**.
425426
- **Region**: Select the same region that you used previously.
426-
- **User name**: Enter a username.
427-
- **Password**: Enter a user password.
428-
1. For **Public inbound ports**, select **Allow selected ports**, and then select **RDP (3389)**.
427+
- **Image**: Ubuntu Server 22.04 LTS - x64 Gen2
428+
- **Size**: Standard_B2s
429+
- **Authentication type**: SSH public key
430+
- **Username**: **azureuser**
431+
- **SSH public key source**: Generate new key pair
432+
- **Key pair name**: **VM-Onprem_key**
433+
1. For **Public inbound ports**, select **None**.
429434
1. Select **Next: Disks**.
430435
1. Accept the defaults and select **Next: Networking**.
431436
1. For the virtual network, select **VNet-Onprem**. The subnet is **SN-Corp**.
432437
1. Select **Next: Management**.
433438
1. Select **Next: Monitoring**.
434439
1. For **Boot diagnostics**, select **Disable**.
435440
1. Select **Review+Create**, review the settings on the summary page, and then select **Create**.
441+
1. On the **Generate new key pair** dialog, select **Download private key and create resource**. Save the key file as **VM-Onprem_key.pem**.
436442

437443
[!INCLUDE [ephemeral-ip-note.md](~/reusable-content/ce-skilling/azure/includes/ephemeral-ip-note.md)]
438444

445+
## Deploy Azure Bastion
446+
447+
Deploy Azure Bastion in the hub virtual network to provide secure access to the on-premises virtual machine.
448+
449+
1. Navigate to the **VNet-Hub** virtual network.
450+
1. Select **Subnets** > **+ Subnet**.
451+
1. Configure the new subnet:
452+
- **Name**: **AzureBastionSubnet** (this exact name is required)
453+
- **Starting address**: **10.5.3.0**
454+
- **Subnet size**: **/26 (64 addresses)**
455+
1. Select **Save**.
456+
457+
1. On the Azure portal menu, select **Create a resource**.
458+
1. Search for **Bastion** and select it.
459+
1. Select **Create**.
460+
1. Configure the Bastion deployment:
461+
462+
| Setting | Value |
463+
|-----------------------|---------------------------------|
464+
| Subscription | Your subscription |
465+
| Resource group | **RG-fw-hybrid-test** |
466+
| Name | **Hub-Bastion** |
467+
| Region | Same location as other resources |
468+
| Tier | **Developer** |
469+
| Virtual network | **VNet-Hub** |
470+
| Subnet | **AzureBastionSubnet** (auto-selected) |
471+
| Public IP address | Create new |
472+
| Public IP address name | **Bastion-pip** |
473+
474+
1. Select **Review + create**.
475+
1. Select **Create**.
476+
477+
The deployment takes about 10 minutes to complete.
478+
439479
## Test the firewall
440480

441481
1. Note the private IP address for the **VM-Spoke-01** virtual machine.
442482

443-
1. On the Azure portal, connect to the **VM-Onprem** virtual machine.
483+
1. On the Azure portal, connect to the **VM-Onprem** virtual machine using Azure Bastion:
484+
- Navigate to the **VM-Onprem** virtual machine
485+
- Select **Connect** > **Connect via Bastion**
486+
- Select **Use SSH Private Key from Local File**
487+
- For **Username**, type **azureuser**
488+
- Browse to and select the **VM-Onprem_key.pem** file
489+
- Select **Connect**
444490

445-
1. Open a web browser on **VM-Onprem**, and browse to `http://<VM-Spoke-01 private IP>`.
491+
1. From the SSH session on **VM-Onprem**, browse to the spoke web server:
446492

447-
The **VM-Spoke-01** webpage should open.
493+
```bash
494+
curl http://<VM-Spoke-01 private IP>
495+
```
496+
497+
The **VM-Spoke-01** webpage should open, displaying the hostname.
448498

449-
![Screenshot that shows the webpage for the spoke virtual machine.](media/tutorial-hybrid-portal/VM-Spoke-01-web.png)
499+
1. From the **VM-Onprem** SSH session, open an SSH connection to **VM-Spoke-01** at the private IP address:
450500

451-
1. From the **VM-Onprem** virtual machine, open a remote access connection to **VM-Spoke-01** at the private IP address.
501+
```bash
502+
ssh azureuser@<VM-Spoke-01 private IP>
503+
```
452504

453-
Your connection should succeed, and you should be able to sign in.
505+
Your connection should succeed, and you should be able to sign in. Type **exit** to close the connection.
454506

455507
Now that you've verified that the firewall rules are working, you can:
456508

457509
- Browse to the web server on the spoke virtual network.
458-
- Connect to the server on the spoke virtual network by using RDP.
510+
- Connect to the server on the spoke virtual network by using SSH.
459511

460512
Next, change the action for the collection of firewall network rules to **Deny**, to verify that the firewall rules work as expected:
461513

0 commit comments

Comments
 (0)