Logging onto Cloud

Overview

Teaching: 30 min
Exercises: 5 min
Questions
  • How do I connect to an instance on the SURFsara’s cloud?

Objectives
  • Log onto to the cloud user interface

  • Start a VM based on a template

  • Log off from a running instance

Important Note

This lesson covers how to start a VM based on a already created image and template, and log in and out of a running instance. This lesson is an adapted version of the SURFsara HPC tutorial

If you’re returning post-workshop and want to launch your own instance, use follow the SURFsara tutorial on how to create a template and instance from scratch.

Background

To save time, your instructor configured a template for a virtual machine for you prior to the workshop, and connected it to our lesson data.

Access the User Interface

The User Interface (UI) is the web site that allows you to manage your Virtual Machines (VMs) on the HPC Cloud.

Log in to the UI

Note

You will receive your access credentials from the workshop facilitators.

Add your public SSH key

To complete the setup of your HPC Cloud account, you need to add a Secure Shell (SSH) public key to your UI account. This is a one-time task!

Note

If you are not familiar with the SSH authentication method, please read about it on our documentation page.

First, you need to own an SSH private/public key pair.

To create a new SSH key pair:

  1. Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
  2. Generate a new ED25519 SSH key pair:

ssh-keygen -t ed25519 -C "email@example.com"

Or, if you want to use RSA:

ssh-keygen -o -t rsa -b 4096 -C "email@example.com"

The -C flag adds a comment in the key in case you have multiple of them and want to tell which is which. It is optional.

  1. Next, you will be prompted to input a file path to save your SSH key pair to. If you don’t already have an SSH key pair, use the suggested path by pressing Enter. Using the suggested path will normally allow your SSH client to automatically use the SSH key pair with no additional configuration.

If you already have an SSH key pair with the suggested file path, you will need to input a new file path and declare what host this SSH key pair will be used for in your ~/.ssh/config file.

  1. Once the path is decided, you will be prompted to input a password to secure your new SSH key pair. It’s a best practice to use a password, but it’s not required and you can skip creating it by pressing Enter twice. If, in any case, you want to add or change the password of your SSH key pair, you can use the -pflag: ssh-keygen -p -o -f <keyname>

Next, you need to copy the public SSH key (id_rsa.pub) to the UI. The matching private key (id_rsa) remains safe in your laptop.

My first VM

Working with the HPC Cloud service mostly revolves around building and destroying Virtual Machines. This section will guide you through the process of building a VM running Linux. Here’s an overview of the main steps you will be taking:

Let’s create your first VM to be run on the HPC Cloud Oort!

Cloning a template

Reviewing the Template

A template consists of a set of attributes that define how a Virtual Machine should look like. For example, how many cores do you want your VM to have? How much RAM memory? What storage drives to attach? Which network connections, etc. ? You can adapt the template you cloned, so that the VM(s) you create out of it meet the requirements you have.

For this part of the course, we would like you to edit the imported template following these steps:

youselectednetwork

If this is not the case, then under the Inputs section select Type Tablet and Bus USB from the drop-down lists, and finally click the Add button next to those drop-down lists.

Starting the VM

As mentioned earlier, a template is just a description of the Virtual Machine that we want to build. Let’s create the actual VM from it.

An overview of all existing VMs, that you have the priviledges to see, are displayed. This list is (probably) empty at the moment, because you have not yet started any VM.

What happened?

Congratulations! You have just created a fresh, clean Virtual Machine!

Note
Your VM will appear in the list of Virtual Machines. At first, it will have the state PENDING. This indicates that the HPC Cloud is looking for a place where your VM can actually run. Finding the right place depends on the amount and types of resources (cores, memory, disk…) you requested in the template. Keep refreshing the list by clicking the refresh button . When the required resources become available, your VM will show the status RUNNING. Only then you will be able to make use of it.

Let’s summarise what you have seen so far. Click on each of the tabs on the left menu and inspect the information provided. The most important ones at this point are:

Logging in to the Virtual Machine

You can interact with your VM in several ways: command-line (e.g.: SSH), VNC (UI in your browser) or a remote desktop. We will use SSH in a terminal for the time being.

In order to log in to your VM, you will make use of the SSH public key stored in your profile earlier. Proceed as follows:

The IP address of a VM is shown in the IPs column on the VM list, and in the Network tab of the VM details page.

Note

Replace 145.100.5Q.RST with your IP address!

ssh ubuntu@145.100.5Q.RST

You may receive a message like the following:

WARNING: Your password has expired.
You must change your password now and login again!
Changing password for ubuntu.
(current) UNIX password:

In that case, you will have to “change” the password for user ubuntu. Type in the old password (you will not see any characters being typed, but that is expected), which is: ubuntu (without the quote marks). Then hit Enter. After that, type in a new password that you will know, followed by the Enter key. And type that new password again.

You may be logged out after a successful password change. Type the ssh command again that you typed before you were prompted to change the password.

If everything went well, the first time you try to log in your terminal will ask you to add the VM IP to the list of known hosts. Type Yes, in that case.

You should now see a similar line in your terminal: ubuntu@packer-ubuntu-14:~$. This is the prompt of your VM and is waiting for your input. You have logged in successfully!

ubuntu@packer-ubuntu-14:~$ ls /
ubuntu@packer-ubuntu-14:~$ whoami
ubuntu@packer-ubuntu-14:~$ echo "Hello HPC Cloud!" > myfile
ubuntu@packer-ubuntu-14:~$ cat myfile
ubuntu@packer-ubuntu-14:~$ logout

Food for brain

Log in to your VM again. Is your file still there?

First shutdown

Let’s shutdown your VM. Whenever you do not need your VM running, you should shut it down to stop consuming the resources allocated.

You can always boot the “same” VM again whenever you need it, from the corresponding template.

Food for brain

When the VM has been shut down and disappeared from the list, check and refresh the Storage > Images and Templates > VMs tabs. Are your image and template still there?

The HPC Cloud has hundreds of users. Many of them have common questions. In order to address these we have put together a web site with some documentation, we call it the HPC Cloud Documentation. Do you know the URL of this web site? Make sure you find out!

Key Points

  • You can use one set of log-in credentials for many instances

  • Logging off an instance is not the same as turning off an instance