# Lab Answer Key: Module 4: Virtual Machines
Lab 1: Creating a Linux Virtual Machine
Please note that the virtual machine that you will create in this lab will also be used in the next lab of this course.
Lab exercises:
- Create cryptographic keys
- Create and connect to a Linux virtual machine
Exercise 1: Create cryptographic keys
Scenario: In this exercise you will create cryptographic keys that you will use to connect via PuTTY to the Azure virtual machine that you deploy later in this lab.
The main tasks for this exercise are as follows:
- Install Git for Windows
- Create a key pair
- Create a private key for PuTTY
Task 1: Install Git for Windows
- Start Internet Explorer and browse to https://git-for-windows.github.io/
- Click on the Download link.
- When prompted whether to run or save the Git executable, click Run.
- In the Git 2.11.0 Setup wizard, accept the default settings and complete the install.
- Once the install completes, on the Completing the Git Setup Wizard page, select the Launch Git Bash checkbox and click Finish. Alternatively, from the Start menu (or screen), start Git Bash.
Task 2: Create a key pair
- In the Git Bash window, run the following:
openssl.exe req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout myPrivateKey.key -out myCert.pem
- When prompted, provide the information to be incorporated into the certificate you are generating, including country code, state or province, locality name, organization name, organizational unit, common name, and email address (for the purpose of this lab, you can use made up values).
- Generate a public key by running:
openssl.exe rsa -pubout -in myPrivateKey.key -out myPublicKey.key
Task 3: Create a private key for PuTTY
- Convert the private key you generated in the previous task into a private key that you will be able to use with the PuTTY utility. In the Git Bash window, run the following:
openssl rsa -in ./myPrivateKey.key -out myPrivateKey_rsa
- Download PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html to the C:\Users_username folder, where username is your Windows user account name. This is the same location where the keys you generated in the previous task reside.
- In the File Explorer window, double-click puttygen.exe.
- In the PuTTY Key Generator window, click Load.
- In the Load private key dialog box, make sure that the current directory is C:\Users_username, where username is the name of your user account, change filter to All Files (.), select myPrivateKey_rsa and click Open.
- In the PuTTYgen Notice dialog box, click OK.
- Copy the entire content of the Public key for pasting into OpenSSH authorized_keys file section of the PuTTY Key Generator window into Clipboard.
- In the PuTTY Key Generator window, click Save private key
- Save the private key as myPrivateKey_rsa.ppk in the C:\Users_username directory (where username is your Windows user name). Click Yes in the PuTTYgen Warning dialog box, when prompted whether to save the key without a passphrase to protect it. Note that you have the option of protecting it with a passphrase.
Note: Outside of a lab environment, you should use a passphrase and file system permission to protect your private key.
Exercise 2: Create and connect to a Linux virtual machine
Scenario: In this exercise you will create a new Linux virtual machine by using the Azure portal and use the key you generated to connect to it.
The main tasks for this exercise are as follows:
- Create a new Linux virtual machine by using the Azure portal
- Connect to the Linux virtual machine by using PuTTY
Task 1: Create a new virtual machine
- Start Internet Explorer and browse to https://portal.azure.com
- Click on the +New link.
- Select Compute in the blade that comes up.
- In the Compute blade select See all.
- In the Filter text box, type Ubuntu Server and press Enter
- In the list of results, click the latest recommended version of the Ubuntu Server.
- Ensure that the deployment type is set to Resource Manager and click Create.
- On the Basics blade, specify the following and click OK.
- Name: LABLinuxVM
- VM disk type: HDD
- User name: Student
- Authentication type: SSH public key
- SSH public key: paste the content of Clipboard
- Resource group: create a new resource group called LABLinuxRG
- Location: an Azure region closest to your physical location
- On the Choose a size blade, click DS1_V2 size and click Select.
- On the Settings blade, accept the default settings and click OK.
- On the Summary page, click OK
Task 2: Connect to the Linux virtual machine by using PuTTY
Note: You need to wait until the new virtual machine has been provisioned. This should take a couple of minutes. The Azure portal will automatically display the new blade showing the settings of the new virtual machine.
- In the Azure portal, in the Overview section of the LABLinuxVM blade, note the Public IP address assigned to the VM
- Start Internet Explorer and browse to http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Download putty.exe to your computer and click Run when prompted.
- In the PuTTY Configuration window, type the IP address you noted in step 1 in the Host Name (or IP address) text box.
- In the Category section of the PuTTY Configuration window, expand the Connection->SSH nodes and click Auth.
- Click Browse next to the Private key file for authentication text box.
- In the Select private key file dialog box, navigate to the C:\Users*username directory (where username is your Windows user name), select myPrivateKey_rsa.ppk and click Open.
- When prompted by the PuTTY Security Alert, click Yes.
- In the PuTTY window, when prompted for the username, type in Student and verify that you have successfully authenticated.
No comments:
Post a Comment