Logging onto Cloud
Overview
Teaching: 30 min
Exercises: 5 minQuestions
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.
- Open the UI page in your browser: https://ui.hpccloud.surfsara.nl/
- Enter the username & password provided
- Hit the
Login
button
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:
- Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
- 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.
- 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.
- 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.
- Copy the content of your public SSH key to the clipboard (e.g.
cat ~/.ssh/id_rsa.pub
, then select and copy all the text) - Go to the UI and select Settings from the buddy icon
- Locate the section Public SSH Key and click on the blue edit icon
- Paste the content of your public SSH key file into the text box
- There is no Save button. Click outside the text box to complete your action
- Briefly check the contents of the text box against your public key and verify they match: it should start with
ssh-rsa AAAAB
…
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:
- Clone a template and images
image
with a Linux operating system installed - Reviewing the VM attributes defined in the
template
- Instantiating the
template
to run your first VM - Accessing your VM and gracefully shut it down
Let’s create your first VM to be run on the HPC Cloud Oort!
Cloning a template
- Go to the VMs tab under Templates on the left menu
- Find the
template
with the name “carpentry-genomics-wageningen” and check the tick-box - Click on the blue Clone button in the top menu
- Give the new template a unqiue name, for example adding your name in the end.
- Click on
Clone with Images
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:
- Go to the VMs tab under Templates on the left menu
- Find the
template
created previously and check the tick-box - Click on the blue Update button to start editing the template
- Browse through the different tabs there (i.e. General, Storage, Network, …) to get acquainted with their contents
- Verify that your VM will have internet access:
- Select the Network tab which shows the network interfaces (
NIC
) for your VM - The feedback below tells that the internet interface
NIC 0
on the left pane is mapped tointernet
- Select the Network tab which shows the network interfaces (
- Check the Input/Output tab:
- In the Graphics section, the VNC radio button must be selected
- In the Inputs section, make sure an entry table USB is listed
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.
- If you made any changes to the
template
, click the green button Update at the top, to save your changes.
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.
- Go to the VMs section below Instances on the left menu
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.
- Click the button to bring up a “Create Virtual Machine” screen
- Select your cloned version of carpentry-genomics-wageningen by clicking once on it
- Inspect the
template
attributes, for the time being do not change them (in particular, leave Number of instances at 1) - You can leave the VM Name blank, a number will be appended to the template name
- Click on the green Create button at the top of the screen
- Refresh the list of VMs by clicking button at the top. You will see the status of the VM change
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 statePENDING
. 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 thetemplate
. Keep refreshing the list by clicking the refresh button . When the required resources become available, your VM will show the statusRUNNING
. 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:
- Instances > VMs: here you can manage your VM(s) (e.g.: create, terminate, …). When you click anywhere on a running VM row (except the tick-box) you can inspect the extended information for that VM in the different tabs. You can even change some VM features from these tabs.
- Templates > VMs: here you can manage your templates. The
template
gives your VM the shape you want. It is just a recipe, and not the machine itself. - Storage > Images: here you can manage storage places. You can look at
images
as hard drives. - Storage > Apps: here you can see the list of
appliances
endorsed by SURFsara HPC Cloud team. Oneapp
of course is a bundle of animage
and atemplate
, which provide a basic working set of installed software and configured properties that allow you to easily create and use a VM.
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:
- On the UI: find the VM IP address
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.
-
On your laptop: start a terminal
-
On your laptop: type the following command on the terminal to establish a connection with your VM
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!
- Look around a bit, make yourself familiar with the system:
ubuntu@packer-ubuntu-14:~$ ls /
ubuntu@packer-ubuntu-14:~$ whoami
- Create a file:
ubuntu@packer-ubuntu-14:~$ echo "Hello HPC Cloud!" > myfile
ubuntu@packer-ubuntu-14:~$ cat myfile
- Logout by typing
logout
orctrl-D
in your terminal (do not issue any shutdown command):
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.
- Go to the list of running VMs in the Cloud UI (Instances > VMs)
- Tick the box to the left on the row with your VM
- At the upper right corner of the screen, click the red button and click Terminate
- A confirmation action is needed, click OK
- Refresh the list of VMs () until your VM is gone
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
andtemplate
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