arrow_back

Securing Virtual Machines using BeyondCorp Enterprise (BCE)

Join Sign in

Securing Virtual Machines using BeyondCorp Enterprise (BCE)

1 hour 30 minutes 1 Credit

GSP1036

Google Cloud self-paced labs logo

Overview

In this lab, you will explore how you can use BeyondCorp Enterprise (BCE) and Identity-Aware Proxy (IAP) TCP forwarding to enable administrative access to VM instances that do not have external IP addresses or do not permit direct access over the internet.

You can read more about BeyondCorp Enterprise (BCE) and the zero trust security model at the following cloud documentation site:

Setup

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

You will need a RDP client pre-installed so that you can connect and test Windows instances.

What You’ll Do

  • Enable IAP TCP forwarding in your Google Cloud project
  • Create Linux and Windows Instances
  • Test connectivity to your Linux and Windows instances
  • Configure the required firewall rules for BCE
  • Grant permissions to use IAP TCP forwarding
  • Demonstrate tunneling using SSH and RDP connections

Enable IAP TCP forwarding in your Google Cloud project

  1. Open the Navigation Menu and select APIs and Services > Library.

  2. Search for IAP and select Cloud Identity-Aware Proxy API.

  3. Click Enable.

Cloud Identity-Aware Proxy API

Create Linux and Windows Instances

  1. You will create three instances for this lab

    • Two for demonstration purposes (Linux and Windows)
    • One for testing connectivity (Windows)
  2. Open the Navigation Menu and select Compute Engine

  3. To create the Linux Demo VM. Click Create instance and use the following configuration to create a VM. Leave the rest as default.

Name: linux-iap

Zone: us-east1-c

Click on Networking, disks, security, management, sole tenancy and select Networking. Under network interfaces click the defult network to edit. Then change the External IPV4 address to None.

Click Done.

ntwrk_intrfce

Then click create.

This VM will be referred to as linux-iap

  1. To create the Windows Demo VM. Click Create instance and use the following configuration to create a VM. Leave the rest as default.

Name: windows-iap

Zone: us-east1-c

Under the boot disk section, click on Change

For the OS, select the following:

  • Public Images > Operating system > Windows Server
  • Version > Windows Server 2016 Datacenter

Windows Version Select

Click Select.

Click on Networking, disks, security, management, sole tenancy and select Networking. Under network interfaces click the defult network to edit. Then change the External IPV4 address to None. Click Done.

Then click create.

This VM will be referred to as windows-iap

  1. To create the Windows Connectivity VM. Click Create instance and use the following configuration to create a VM. Leave the rest as default.

Name: windows-connectivity

Zone: us-east1-c

Under the boot disk section, click on Change

For the OS, set the following on the Custom Images tab:

  • Source project for images: qwiklabs-resources
  • Image: iap-desktop-v001

Click Select.

For access scopes, select Allow full access to all Cloud APIs

Do not disable external IP for this instance

Then click create.

This VM will be referred to as windows-connectivity

Check if all 3 instances have been created

Test connectivity to your Linux and Windows instances

  1. After the instances are created, You will test access to linux-iap: and windows-iap: to ensure that you aren’t able to access the VMs without the external IP.

  2. For linux-iap: click on the SSH button to get into the machine and ensure you get a message similar to the following.

    linux_connectionfailed

  3. For windows-iap: click the RDP button and ensure you get a message similar to the following:

    windows_connection_failed

The following steps for configuring and using IAP will allow you to connect to the instances that don’t have external IPs.

Configure the required firewall rules for BCE

  1. Open the Navigation Menu and select VPC Network > Firewall and click Create Firewall Rule

  2. Configure the following settings:

Name: allow-ingress-from-iap

Direction of traffic: Ingress

Target: All instances in the network

Source filter: IPv4 Ranges

Source IPv4 Ranges: 35.235.240.0/20

Protocols and ports: Select TCP and enter 22, 3389 to allow both SSH and RDP respectively

Click CREATE to create the firewall rule.

Check proper firewall rules have been created.

Grant permissions to use IAP TCP forwarding

  1. Follow the following steps to configure the iap.tunnelResourceAccessor role by VM.
    • Open Navigation Menu and select Security > Identity-Aware Proxy, switch to the SSH and TCP Resources tab (safely ignore the Oauth Consent screen error in the HTTPS section).
    • Select the linux-iap and windows-iap VM instances
    • Click Add principal
    • Enter in the service account associated with your Windows connectivity VM.
    • Select Cloud IAP > IAP-Secured Tunnel User for the role.
    • Click SAVE.
    • From the top-right of the page click the "S" icon to open your profile and copy the email of the qwiklabs student account
    • Click Add principal again to add your student account
    • Enter in the student account you have copied
    • Select Cloud IAP > IAP-Secured Tunnel User for the role.
    • Click SAVE.
The IAP-Secured Tunnel User role will grant the windows-connectivity instance to connect to resources using IAP. Adding the student account will help verify the step was done correctly.

Add Principals

Check that IAM roles have been set for the service account.

Use IAP Desktop to Connect to the Windows and Linux Instances

It is possible to use IAP Desktop to connect to instances using a graphical user interface from an instance with Windows Desktop. You can read more about IAP Desktop on the GitHub repository hosting the download for the tool.

To use IAP Desktop to connect to the instances in this lab:

  1. RDP to the windows-connectivity instance by downloading the RDP file. Go to the Compute Engine > VM Instances page. Select the down arrow next to the windows-connectivity instance on the Compute Engine landing page and download the file.

  2. Open the RDP file to connect to the instance via Remote Desktop Protocol. You will use the credentials below to connect to the instance once prompted:

  • Username: student

  • Password: Learn123!

  1. Once connected to the windows-connectivity instance, locate and open the IAP Desktop application on the desktop of the instance.

  2. Once the application opens, click on the sign in with Google button to log in. Use the username and password provided in the lab console to authenticate with IAP Desktop. Make sure you select the option to "See, edit, configure and delete Google Cloud data."

oauth_permissions.png

  1. You will need to add the project to connect to Compute Engine instances within IAP Desktop after authentication. Select the qwiklabs project associated with your lab instance:

add_project.png

Double click on the windows-iap instance in the IAP Desktop application to log into the the instance.

  1. You may be prompted to provide credentials for the instance the first time you try to connect to it through IAP Desktop. Select "Generate new credentials" the first time logging into the instance.

credentials.png

  1. After the credentials are created you will be taken to the desktop of the windows-iap instance and can see the end user experience.

windows_iap.png

Demonstrate tunneling using SSH and RDP connections

  1. You will testconnectivity to the RDP instance using an RDP client. This is because you need to connect to the instance via an IAP tunnel locally.

  2. Go to the Compute Engine > VM Instances page.

  3. For the windows-connectivity instance click the down arrow and select Windows password. Copy the password and save it.

Then click down arrow next to connect and click download the RDP file. Open the RDP file with your client and enter in your password.

  1. Once you have connected to the windows-connectivity instance. Open the Google Cloud Shell SDK:
7

Now from the command line enter the following command to see if you can connect to the linux-iap instance:

gcloud compute ssh linux-iap

Click Y when promopted to continue and to select the zone.

Make sure that you select the right zone for the instance when prompted.

Then Accept the Putty security alert.

You should receive a message that no external IP address was found and that it will use IAP tunneling

8

Update Putty Settings to allow Tunnel connections locally. Click the top left corner of the Putty Window > Change Settings.

Putty Settings

Allow local ports to accept connections from other hosts by checking the checkbox "Local ports accept connections from other hosts". Tunnel Settings

  1. Close the Putty session and click OK. Use the following command to create an encrypted tunnel to the RDP port of the VM instance:

gcloud compute start-iap-tunnel windows-iap 3389 --local-host-port=localhost:0 --zone=us-east1-c

Once you see the message about “Listening on port [XXX].” Copy the tunnel port number.

  1. Return to the Google Cloud Console and go to the Compute Engine > VM Instances page.

Set and copy the password for the windows-iap instance.

Return to the RDP session now.

Leave gcloud running and open the Microsoft Windows Remote Desktop Connection app.

Enter the tunnel endpoint where the endpoint is the tunnel port number from the earlier step like so:

  • localhost:endpoint

    6

Click Connect.

Then enter the previous credentials you copied earlier You will be successfully RDPed into your instance now!

If prompted click Yes.

10

You were able to access the instance even without an external IP address using IAP Confirm VM is accessible via IAP enabled SA Congratulations! You were able to successfully connect to both instances using IAP.

Congratulations

In this lab, you deployed 2 VM's, windows-iap and linux-iap, without IP addresses. Then you configured an IAP tunnel and were able to access both instances using a third VM, windows-connectivity.

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated: July 27, 2022

Lab Last Tested: July 27, 2022

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.