Edit Page

Cloud Computing

Week 4: Cloud Computing: Getting Started

Infrastructure-as-a-Service (IaaS) Cloud Service Providers

Creating a New Virtual Machine (VM) Instance in the Cloud

Logging in to Your Virtual Machine VM Instance

  • To log in to your virtual machine (VM) instance, you need to use SSH.

  • SSH is an encrypted connection protocol that allows secure sign-ins to a remote server.

  • SSH connection can be established using passwords or public–key cryptography.

  • Although SSH is a secure protocol, using passwords makes accessing your VM instance vulnerable to guessing or brute force attacks.

  • A more secure approach of connecting to a remote server using SSH is by using public–key cryptography.

  • Public–key cryptography involves using a public-private key pair, also known as SSH keys, to encrypt and decrypt login information.

  • Your cloud provider stores the public key only inside your instance, and you store the private key.

  • Anyone who possesses your private key can login to your instance or decrypt your login information, so it’s important that you store your private keys in a secure place on your client machine.

  • To add an extra layer of security to your SSH key, add a passphrase to your SSH key.

  • To access your VM instance using SSH keys, you need to have on your client machine a terminal emulator and an SSH client.

  • Below is how to SSH to your VM instance. Replace ip_or_domain with the fully qualified domain name (or IP address).

    ssh -i /home/you/.ssh/your_private_key root@ip_or_domain
    

SSH Clients and Terminal/Console Emulators

  • You need to establish an ssh connection from your client machine into a remote server.
  • The most common SSH access method is through a command line SSH client (remote login program).
  • You need a terminal/console emulator to use the SSH client on your local machine.
    • Windows:
      • Windows Terminal: an open-source, fast, powerful, and modern terminal application by Microsoft.
      • Cmder: A portable console emulator for Windows.
      • Hyper: A terminal built on web technologies.
      • Mintty: A terminal emulator for Cygwin
      • Git for Windows : a BASH emulation with Git support using the console or GUI.
    • macOS
      • Terminal: Apple’s default terminal emulator.
      • iTerm2: An alternative to the default Terminal app
    • Linux
      • xterm: The standard terminal emulator on most linux distributions.

Generating New SSH Key Pair

The following steps assume that you are using a BASH shell on your client machine using the previous step.

  1. Create SSH key pair with OpenSSH using RSA encryption and a bit length of 4096
ssh-keygen -t rsa -b 4096 -C "provide comment to label the key (e.g. my azure keys)"
  1. You will be prompted to enter a path to save the keys and a passphrase
Generating public/private rsa key pair.
Enter file in which to save the key (/home/you/.ssh/id_rsa): /home/you/.ssh/azure_key
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/you/.ssh/azure_key.
Your public key has been saved in /home/you/.ssh/azure_key.pub.
The key fingerprint is:
a7:83:cc:76:83:21:1f:2a:ec:a4:04:11:e5:e3:b1:e8 my azure keys
The key's randomart image is:
+--[ RSA 4096]----+
|...              |
| o               |
|. +              |
| + +             |
|o o . o S .      |
|o.   * = o       |
| E+ . B =        |
|.+ . . . o       |
|. .              |
+-----------------+

This will generate two keys: a private key /home/you/.ssh/azure_key and a public key /home/you/.ssh/azure_key.pub. The passphrase you entered will add an extra layer of security, so you will be asked to enter this passphrase every time you use your SSH keys.

  • To avoid typing your private key file passphrase multiple times, you can use ssh-agent to securely save your private key file passphrase, so you don’t have to reenter it. To start ssh-agent, run:
eval "$(ssh-agent -s)"
  1. Add the private key to ssh-agent using the command ssh-add:
ssh-add ~/.ssh/id_rsa

Adding your new SSH key to your cloud provider account

To configure your VM instance to use your new (or existing) SSH key, you’ll also need to add your public key to your cloud provider account (e.g., Azure web portal/console).

  1. Print out your public key, so you can copy it:

    cat ~/.ssh/azure_key.pub
    
  2. Add your public key into the VM instance when creating it using the web console interface by either uploading it or pasting its content in the appropriate place when creating a new VM. See the links below for your cloud provider of choice.

Note: You may add the public key into an existing VM instance. Please refer to the documentation of your cloud provider.