Skip to content
Permalink
cd2a470a7d
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
259 lines (259 sloc) 11.3 KB
{
"cells": [
{
"cell_type": "markdown",
"id": "1ca096dd",
"metadata": {},
"source": [
"# Setup for Azure CLASS essentials episodes\n",
"\n",
"```{admonition} Overview\n",
":class: tip\n",
"\n",
"**Teaching:** 10 mins\n",
"\n",
"**Exercises:** 2 mins\n",
"\n",
"**Questions:**\n",
"* What is Resource Group and how do a create one?\n",
"* How do I open Azure Cloud Shell?\n",
"* How do I provide secure login access to my compute resources?\n",
"\n",
"**Objectives:**\n",
"* Create Resource Group\n",
"* Find and open the Cloud Shell\n",
"* Generate a ssh key\n",
"* Create a key stored in Azure using the \"SSH Key service\"\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "5accf0bf",
"metadata": {},
"source": [
"# Resource Group\n",
"\n",
"Almost everthing you do in Azure requires a Resource Group. A Resource Group is a \n",
"logical container that associates multiple resources so you can manage them as a \n",
"single entity. The resource group collects metadata from each individual resource \n",
"to facilitate granular management. This not only has advantages for administration \n",
"and cost management but also for applying role-based access controls."
]
},
{
"cell_type": "markdown",
"id": "5df56e70",
"metadata": {},
"source": [
"# Create a Resource Group\n",
"\n",
"To create a Resource Group from the console, click the pull down menu on the \n",
"left (you can also type \"resource group\" in the search bar to find this service). Click on \"Resource Groups\" from the menu. This will bring you to the \n",
"\"Resource Groups\" page. Click the \"+ Create\" button. Under the \"Basic\" tab you \n",
"should see your \"Subscription\" (verify that you are using the correct subscription) \n",
"and under that you will see \"Resource group\". In the \"Resource group\" window, enter **essentials**. \n",
"Under \"Resource details\", choose \"(US) East US\" for the region. We will put all of \n",
"our resources in the \"(US) East US\" region. Now click the \"Review + create\" button. Once you see a green check mark \n",
"with \"Validation passed\", click create. We will use this resource group for the remainder \n",
"of the lesson."
]
},
{
"cell_type": "markdown",
"id": "8d4a9865",
"metadata": {},
"source": [
"## Cloud Shell\n",
"The cloud shell button invokes an interactive shell environment for either bash or PowerShell. The first time you invoke cloud shell you will also create persistent storage specifically for cloud shell. The cloud shell comes with linux tools like bash, sh, & dig as well as the Azure CLI. Cloud shell also has editors like VIM and emacs, and tools like git, make, and configuration tools like ansible & terraform already installed. Language support for python, go, java, & PowerShell are also preinstalled. Azure Cloud Shell runs on Ubuntu 16.04 LTS with persistent storage."
]
},
{
"cell_type": "markdown",
"id": "597fab30",
"metadata": {},
"source": [
"## Open the Cloud Shell\n",
"\n",
"The Cloud Shell is an easy way to access Comand Line Interface (CLI) commands in a web browser. Under the hood Cloud Shell is Common Base Linux Delridge (CBL is a free and open-source, Linux distribution that Microsoft has developed) OS running in a container with 5GB of persistent storage and a lot of other useful tools (git, jq, Docker, etc.) installed by default.\n",
"To use the Azure Cloud Shell:\n",
" \n",
" * Open up a Cloud Shell by clicking on the cloud shell icon (greater than sign followed by underscore) on the blue bar just to the right of search window. On first launch, the Cloud Shell will prompt you to create a resource group, storage account, and Azure Files share on your behalf. This will open a cloud shell at the bottom of your browser window. Make sure to choose bash shell from the options if not already chosen.\n",
" * If you want a new cloud shell in a different window, click the new cloud shell button (file icon with + in upper right corner) on the cloud shell menu bar. This will create a new cloud shell window in a new tab in your browser. **Note:** you may need to allow popups or enable popups for this website depending on the browser you use. You can also pull up the Cloude Shell bar to increase the shell screen size.\n",
" * To quit cloud shell type exit at the prompt.\n",
"\n",
"To use the Cloud Shell:\n",
" * Open up a Cloud Shell by clicking on the **Cloud Shell** icon in the right side of the top blue bar (number 3 above).\n",
" * The first time you open cloud shell you will be prompted for the following:\n",
"![welsome-to-cloud-shell-bashl](images/welcome-to-cloud-shell-bash.png)\n",
" * Choose *bash* to continue.\n",
" * Then it will ask you to create a storage account for persistant storage for your cloud shell experience.\n",
"![welcome-to-cloud-shell-storage](images/welcome-to-cloud-shell-storage.png)\n",
" * Click create storage (The storage will incur a nominal fee)\n",
" * Once the Cloud Shell is open and has initialized, you should see \"Welcome to Azure Cloud Shell\".\n",
" * Click the middle box icon on the right side of the Cloud Shell bar to maximize the screen. You can find the correct icon by hovering over the icons to see their names.\n",
" * Note: You can open the Cloud Shell in a new browser tab by clicking on the \"Open new session\" icon (looks like a box with a \"+\") in the middle of the Cloud Shell bar.\n",
"\n",
"![Azure-cloud-shell](images/Azure-cloud-shell.png)\n",
"\n",
"You will notice that in the upper left corner of the cloud shell there is a pull down menu. This should be set to **bash** (The other option is PowerShell). We will now prepare for the next episode by creating an ssh key."
]
},
{
"cell_type": "markdown",
"id": "96fcff2a",
"metadata": {},
"source": [
"## Generate ssh keys\n",
"\n",
"Now we will create a ssh key pair to use with some of the other episodes (e.g. we need a ssh key when creating a VM in order to securely login).\n",
"\n",
"At the **$** prompt, enter **ssh-keygen** and follow the prompts."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "be8b4eb8",
"metadata": {},
"outputs": [],
"source": [
"$ssh-keygen\n",
"Generating public/private rsa key pair.\n",
"Enter file in which to save the key (/home/<username>/.ssh/id_rsa):"
]
},
{
"cell_type": "markdown",
"id": "16814fc2",
"metadata": {},
"source": [
"This prompt is asking you to create a .ssh directory in your home directory and generate ssh public/private keys named id_rsa.pub/id_rsa (default) respectively.\n",
"\n",
"Press enter to continue to create the key. You will see another message asking you for a passphrase, similar to the following:\n",
"```\n",
"Generating public/private rsa key pair.\n",
"Enter passphrase (empty for no passphrase):\n",
"```\n",
"Here you should enter a passphrase (a series of words) to protect the key. You will be asked to re-enter the passphrase as shown below:\n",
"```\n",
"Enter same passphrase again:\n",
"```\n",
"\n",
"After successfully retyping the passphrase the key generation process will continue showing a similar message as follows (the fingerprint and art will look different):\n",
"```\n",
"Your identification has been saved in /home/<username>/.ssh/id_rsa.\n",
"Your public key has been saved in /home/<username>/.ssh/id_rsa.pub.\n",
"The key fingerprint is:\n",
"SHA256:D9yj1nZEUigahirvjkIFoCP7RfjDu67Ku88M7nHQftI learner@cs-748001990186-default-boost-r9phq\n",
"The key's randomart image is:\n",
"+---[RSA 2048]----+\n",
"|o . .. |\n",
"|.. .. o . .. |\n",
"|+ o... o .. . |\n",
"|ooo= .. . o |\n",
"|.+..= S o . |\n",
"| o+..o = o |\n",
"|.+.+.E o + . |\n",
"|+.B o. . . . |\n",
"|=O**o |\n",
"+----[SHA256]-----+\n",
"```\n",
"\n",
"The ssh key generation is now complete. You will only need to do this once for \n",
"your account. "
]
},
{
"cell_type": "markdown",
"id": "1fd46460",
"metadata": {},
"source": [
"Later during the VM (Virtual Machine) creation process we will use this key to provide \n",
"secure login access to your VM.\n",
"\n",
"First, you will need to Cut & Paste the public key you just created. To Cut (copy) your \n",
"public key to your clipboard, run the following command."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a65b40b",
"metadata": {},
"outputs": [],
"source": [
"cat /home/<user-account>/.ssh/id_rsa.pub"
]
},
{
"cell_type": "markdown",
"id": "458dfc14",
"metadata": {},
"source": [
"Highlight the output string with your cursor starting with ssh-rsa until the end of the \n",
"string (white text) and before you come to the green command prompt. With the public key \n",
"highlighted, use the copy command (depending on OS) to put it in your clipboard \n",
"(i.e. for mac use command c)."
]
},
{
"cell_type": "markdown",
"id": "46db1f1e",
"metadata": {},
"source": [
"Now go back to the console and in the search bar type \"ssh\". Under Services, click on the \n",
"\"SSH keys\" service. This will bring you to the SSH key service page. Click Create to go \n",
"to the \"SSH key\" creation page. First, verify that you are using the correct subscription. \n",
"In the \"Resource group\" window, use the pull down menu to the right and choose the \n",
"\"essentials\" Resource Group that we created earlier. Under Region, make sure you are in \"(US) East US\". \n",
"Next, in the \"Key pair name\" window enter **essentials-public-key**. Under the \n",
"\"SSH public key source\" window, click the pull down menu and choose\"Upload existing public key\". \n",
"In the \"Upload key\" box, paste the key that we cut (copied into your clipboard) earlier by \n",
"clicking in the box and paste it using the paste command supported by your OS (i.e \n",
"for mac use command v). Make sure there are no extra white spaces on either end of the \n",
"string. Click \"Review + create\" and after validation click create.\n",
"\n",
"We will use this key when we create a VM.\n",
"\n",
"You can now close the cloud shell by clicking on the X in the upper \n",
"right of the cloud shell window."
]
},
{
"cell_type": "markdown",
"id": "d9f73fa6",
"metadata": {},
"source": [
"```{admonition} Exercise\n",
":class: attention\n",
"\n",
"* What are two ways to find the Resource Group service page?\n",
"* What is the main function of a ssh key pair?\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}