Setting up a machine in the cloud
Overview
Teaching: 10 min
Exercises: 0 minQuestions
How do I create and configure a virtual machine I can control
How can I clean up my virtual machine when I’m done with it
Objectives
Get an idea of how you create a new virtual machine, for example in Microsoft Azure
Know what settings and options are important to consider when creating a new virtual machine
Be aware how you clean up to avoid unexpected costs
You do not need to perform these steps during this workshop!
The steps in this lesson are only meant to discuss how you can start up your own virtual machine. In this lesson, your instructor will have done these already, and just provide you with a username and password that you can work with. The reason we still discuss it is to give you an idea of what needs to be done to start up the computer.
As a first step, we will start a Virtual Machine in the cloud. In this example we will use Microsoft Azure, but if you use another provider (e.g. Amazon, Google) the procedure will be similar. A list of providers you can consider was provided in the first lesson, but these steps should be quite similar for almost all cloud providers and hosters who offer Virtual Private Servers (VPS).
Starting a new Virtual Machine
After you set up an account (and possibly configure how billing works), most cloud providers have some portal or dashboard. There you can typically find some option to create a new Virtual Machine (or whatever the service is called by your cloud provider of choice).

When you want to start a new instance, there are typically a number of things you need to choose and configure. Typical things you can choose are:
- The type of machine, in particular how many (v)CPU’s are available and how much RAM
- Which image or operating system is used to create the machine.
- (With big providers) in which part of the world the server should be hosted. If possible, try to minimize geographic distance!
The number of vCPU’s typically determines how many computations you can run in parallel. Most current day laptop have 2 or 4 CPU cores, an 8GB to 16GB of RAM. However, if your program is unable to make use of multiple cores (as most programs are), having a single vCPU would be sufficient unless you want to run the same program multiple times in parallel.
Furthermore, you typically also can assign a name to the Virtual Machine, and link it to some billing account. In the Azure portal, choose which type of Virtual Machine can be done under the size setting:

With Azure, you can choose between Windows Server or Linux based virtual machine. In this workshop, we will go with Linux.
Which Operating System to Use
If you are familiar with Windows, and want to run a program that you use on your own Windows computer, you can consider using a Windows VM. Remote control of such virtual machines usually happens via Remote Desktop, which behaves very similar to working on a local Windows computer. However, Windows Virtual Machines are more expensive due to licensing costs, not all cloud providers offer them and for servers, Linux is in general more popular for servers. There are estimates that over 90% of the servers in the world and in cloud computing run Linux, and even on Microsoft’s Azure cloud platform Linux virtual machines are more popular than Windows virtual machines.
There are many different Linux based operating systems, often called distributions. For server computing, some notable ones are Ubuntu, Debian, Red Hat, CentOS an SUSE. For beginners, Ubuntu and Debian are perhaps easier to start with. As Ubuntu offers a bit more recent packages, whereas Debian favors stability, we will work with Ubuntu in this lesson. However, almost all the things you learn will be applicable in any kind of Linux/UNIX system. The major differences turn up when you want to install software. Ubuntu and Debian use that
apt
package manager, whereas Red Hat and CentOS use theyum
package manager. Package managers are like app stores: they make it really easy to install new software on a system.
The next step is to set up a user. This will typically be an administrator account that we can use to connect to and manage the machine. We also want to enable SSH access to the machine (port 22 should be open, and not blocked by a firewall), so we can connect to the machine and login as this user.

Security is important!
Please take care in securing your virtual machine, even if you only use it for simple computations. For hackers and criminals, controlling machines can help them do all kinds of malicious things, and if this happens on a virtual machine you have created this can cause you trouble. Therefore, you should always us a strong, unique password for an account with administrator privileges and keep that password safe. It would be even better to consider using private key authentication, if possible.
Finally, your virtual machine needs storage space (the virtual equivalent of a hard drive). Unless you need to store vast amounts of data, you can typically stick with a default amount (on a Linux system something like 20GB should be sufficient for many use cases). Typically, we can also add additional storage, but for this lesson we do not need to and stick to the default.

Once we have configured CPU’s, memory, storage, the operating system and a standard user, we are ready to go. Review other settings, but you will probably be fine with the defaults. At the end, you will problably have to confirm that you want to start up the Virtual Machine.

It may take a little bit of time before the machine is configured at has started, but at some point you should get a notification that your machine is ready to use.

Now that our Virtual Machine is started, we should connect to it. Typically, when we navigate to the Virtual Machine in the portal of the cloud provider, we should see some information needed to connect to it. In Azure, there is a nice landing page that contains multiple option, include a Connect button that will give you more information on how to connect, the option to Stop or Delete the virtual machine, as well as the IP address of the virtual machine.

The IP-adress is important information that will allow you to connect to the remote computer. In case you created a Windows based virtual machine, you can enter this into a Remote Desktop Connection (RDP) client to connect to the computer. In case of a Linux virtual machine, you need to this connect to enter this into a Secure Shell (SSH) client to connect and control the computer.
In the next episode we use this information to connect to the virtual machine.
Cleaning Up
At some point, you are done with your virtual machine and do not need it any more, you should shut it down and delete it. Typically, you can do so via the management page of the virtual machine, for example the one you can see in the figure above. Note that there may be resources related to your machine that are not deleted automatically once you delete te machine. It is a good idea to check if all resources have been removed and deleted to avoid unexpected costs and billing!
Avoid unexpected billing costs!
Some cloud providers, including the large ones such as AWS, Azure and Google cloud bill you for different resources separately. Things that may be billed separately can be:
- Running virtual machines
- Disks and storage space
- Networking (traffic, IP addresses, hostnames)
- Monitoring and Analytics services
Once you are done with your virtual machine it is thus very wise to double check if all (billable) resources are deleted from your account. If you are not going to use cloud services for a while, you can even consider to remove all services in your account just to be sure.
Key Points
Understand that CPU, RAM, Disk Space, Operating System and a administrative user are needed when you create a new virtual machine
Understand that a hostname and/or IP address is needed to connect to a virtual machine, either using Secure Shell (SSH) or Remote Desktop (RDP)
Be aware that you delete/stop all resources when you are finished with you virtual machine, to avoid unexpected costs.