Mining with Amazon Web Services

How to Use a Virtual Machine to Mine Altcoins

This article or tutorial is unfortunately not intended as an instruction manual for making a profit with cryptocurrency using rented machines under any circumstances, certainly not with AWS instances (which is what we will be using as an example here). Besides, you don’t want Mr. Bezos knocking on your door for his share of mining profits (always read the fine print). But on a serious note, if you want to start mining for hobby or profit, you’ll do much better picking up some equipment of your own. You can easily find used ASIC miners or GPUs on Amazon or eBay. Hobbyists can take the time to set up their own custom “mining farms” from scratch. As Core’s mining section evolves, we’d love to write about neat stuff like that, so we’ll have to see how things turn out.

Mining certainly has its share of love and hate. I’ve heard miners described as “The closest you’ll ever get to a money printer”. I’ve also heard them described as “great heaters”. Anyhow, as we go down this burgeoning path of ones and zeros, some of us are going to give it a try – right? I heard all the cool kids are doing it!

So, the purpose of this article is to teach you how to get yourself comfortable “behind the wheel” so to speak. So whatever your ultimate goal is; If you just want to “play house” for a day, or you don’t want to waste any time before your personal server farm comes in the mail, this should whet your appetite, as they say. So let’s take a swim, shall we?

Now, if you’re already familiar with AWS, for the purpose of this article, we’re going to use a “Free Tier” instance to demonstrate CPU mining. But if you’d like to already know how to use Spot Requests, you’re more than welcome to.

Getting Started

Signing up as a new AWS user
AWS Mining | Crypto Core Media

AWS isn’t tied to a “standard” Amazon account. So when you head over to and type in your normal username and password, it will act basically as if you do not have an Amazon account. Don’t worry, this is normal. It may be a bit inconvenient, but you’ll need to sign up for AWS separately. A bit of a drawback, sure, but nothing you can’t handle, right? Be prepared to provide a debit card and ID verification like Azure or most of the other VPS providers out there.

Logging In

awc mining

Once you’ve signed in, you can take a look at their GUI and check out the lay of the land. It may seem a bit complicated at first, but we’re only going to be using a small portion of what they have to offer, so don’t worry about it. Since this is probably your first time using AWS, you’ll have noticed that they’re offering a “Free Tier” of applications that you can use for a limited amount of time. This includes EC2 services, the section that virtual private servers or VPS are listed under.

It’s important to note that AWS, which stands for Amazon Web Services is a full-fledged entity of relative complexity, and what we’re going to be using here today is really only a fraction of what it fully offers. To avoid being charged more than you’re expecting, just be careful. Read through the details of whatever you’re using so you don’t end up getting billed unnecessarily. And if you have to, you can open up your calculator app to figure out how much something will ultimately cost to run and for how long. Spot Instances are very important if you’re going to mine with something other than the free tier instance. You’ll save yourself an exorbitant amount of money. So stay tuned for our next installment when we spin up a spot instance to GPU mine a coin.

Time to Spin Up our VPS!

Alright, now that we’ve got all that out of the way. First, we’re going to test mine a coin called Monero (XMR) with one of Amazon’s “free” VPS instances. Just in case we get lucky and end up mining a significant enough amount of Monero to keep, we’ll need a wallet to store it in. (We’re being really optimistic here. The chance that you’ll mine anything significant today is very slim. But hey, you never know, right? Provide any information it asks and copy your “receive” address. You’re going to need that.

Next, we’re gonna get into some really hardcore stuff – so fasten your seatbelt. You’ve heard of Linux before, right? Not your Cousin Tommy’s pet turtle. But he probably knows what we’re talking about, (Your Cousin. Not the turtle).

The first thing we’re going to need is a way to communicate with our VPS. I’m already assuming you’re reading this on Windows or OSX, because if you’re on a tablet – I’m just going to assume you really like me or the way I write. That’s fine with me either way, but let’s move on shall we?

For Windows, there are are several SSH Clients available for use. We’re doing this demonstration in Windows 10, and PuTTY is one of the more popular clients available – (gotta love some PuTTY), so we’re going to use it! The latest release of PuTTY is available here. Using OSX, you have several options, including the built-in & ported client. Whichever OS you’re on, don’t forget to add PuTTYGEN – Windows, OSX.

Either way, excluding this next section, most of the rest of this tutorial will take place in the aforementioned programs.

Alright, so let’s ride!

First, we need to create a VPS in AWS. First, choose the “Services” tab on the top left of the page. When all of the available options are showing, choose EC2, in the Compute section.

Next, a new page will appear that says EC2 Dashboard with a toolbar on the left and Resources in the middle.

aws btc mining

Choose the Instances option from the left toolbar and a new page will appear.

When the next page appears choose either of the blue buttons that say “Launch Instance” and the first major step in creating your VM will appear. In this case, it will say choose an Amazon Machine Image (AMI). Which just means “Pick an OS”!

There are quite a few to choose from. As I was saying, AWS is a complex service that can cover a wide array of tasks and instructions. In our case, we’ll keep it very easy – just pick the fourth down, Ubuntu Server and click Select.


Moving on to the next step. Here’s where you could play around if you had some extra cash, but if you’re going to use anything but one of the free instances. It’s cheaper to pick what you want when you use “Spot Requests”. But we aren’t going to explain that until part 2, which will teach you how to spin up instances with an NVIDIA Grid or Tesla GPU. Back to the task at hand. Choose t2.micro and click “Next: Configure Instance Details”

mining cpu choice

You shouldn’t need to change anything on page 3, 4, or 5, so skip forward to 6. Configure Security Group.

mining security

It’s doubtful that anyone is going to try to infiltrate your Ubuntu VPS and wreak havoc on however long it’s running. But it’s good practice to play it safe, so on this page – you can select the type, SSH, and change the Source to My IP.

Next, attempt to launch your instance, and an important dialog box will appear.

crypto keypair

This allows you to set your key pair for the session. Click the first drop-down menu and choose “Create a new key pair” and name it what you’d like. Click “Download Key Pair” and the .pem file you just named can be downloaded and placed somewhere easy to access.

Crypto mining export

After you export your private key. You can go ahead and click “Launch Instances”. You’ll have some work to do while it spins up.

Open PuTTYGEN while you’re waiting for the VPS to spin up, we’ll need to convert the .pem to allow PuTTY to connect to the instance. Either click File > Load private key or click the Load button under generating and head to the directory where you placed the key. The key generator won’t be able to read Amazon’s .pem file initially, so just change the file type from *.ppk to All Files (*.*) and you’ll see your .pem key. Click “Save private key” in PuTTYGEN, and it will prompt you to protect the key with a password. It’s not necessary but do so if you wish.

Hash Mine PEM

By now, your VPS should be launched and ready to go. Go back to your AWS browser window and copy the Public DNS underneath the list of running instances.

public dns for mining

Here is where the real fun starts. Now you can open PuTTY and paste the Public DNS you got from AWS into the Host Name field.

putty for mining

In our last step of setting up our SSH session, we need to add the private key we made with PuTTYGEN. In the list of options on the left side of the PuTTY window, scroll down to SSH and click once on Auth. As seen in the following picture, at the bottom of the Auth window there’s a dialog box where we need to put the private key we made in PuTTYGEN.

Click Browse, find the .ppk file you made earlier, and click open. Now that the private key is in its place, you can scroll back up to the top of the list of options and click the first one that says Session. So you don’t lose any of the settings you painstakingly made, go ahead and save the session.

mining ssh

Now you can go ahead and connect to your newly created VPS instance. A warning window will pop-up about your key files, but go ahead and ignore it.

cryptocurrency mining ssh

After you connect, you’ll be greeted with a fresh SSH login screen. Login as ubuntu and you’ll end up at the command prompt.

ssh for mining

All code you’ll be entering from here on will be in bold. Generally, as a rule, the first two things you should do when connecting to a fresh VPS are:

sudo apt-get update

sudo apt-get upgrade

Then you can head on over to GitHub (or use the git clone link below) and download your miner. In this case, we’re going to use Wolf0’s classic cryptonight miner.

First, install these required packages:

sudo apt-get install libcurl4-openssl-dev git

sudo apt-get install build-essential

sudo apt-get install autotools-dev autoconf

sudo apt-get install libcurl3 libcurl4-gnutls-dev


Now to clone the miner:

git clone


And the final step is to compile!

cd cpuminer-multi


CFLAGS=”-march=native” ./configure


make install

Now, barring any errors (unlikely in this case) – you should be good to go. We can find a pool now and take it out for a spin! I chose out of convenience, but you can go to any Monero pool you’d like. FYI, I have heard that Minergate isn’t 100% accurate on its payouts, so my recommendation would be to stay away from them (until there’s some concrete proof for or against the rumor).

Remember the web wallet we set up earlier? Now is when we need that. Find a pool, grab your address (it will look like the very long number below), replace our address with the one you made earlier, and let it fly!

Here’s the command to start the miner:

sudo ./minerd -a cryptonight -o stratum+tcp:// -u 49exFFPAjfxDiUYNEdjeg8RqmG9ssSc3iLAyXf24FTt1GMTnQAybV6K9wUWYz1U6H5h9Uk2QhtpE23FnVcaFbS8Z3BFoCJ8 -p x

minerd hashing

And there we have it! The AWS instance should start hashing away (albeit rather slowly), and you’ve learned how to set-up a Cryptonight miner on a VPS!

For the purpose of this article, I used Monero. Partially because it’s well known, and partially because it’s not that difficult to get running. But if you’re relatively comfortable in Linux, there are a few different CPU coins you can compile miners for and do the same thing. When you’re installing anything in Linux, just pay close attention to the dependencies needed, and check your spelling. Luckily, miners generally have similar code and similar dependencies – so the instructions here on how to compile and install a Cryptonight miner aren’t going to differ much from the instructions on how to compile and install, for example, an M7M (Magi) miner. In our next installment, I’ll teach you how to mine with a GPU in windows and use spot requests on AWS.

Now you’re ready to start your own farm! Or at least help run one for a friend…

Doing this with a free tier AWS instance is essentially useless if you’re trying to mine for profit. But, there are ways to make this more affordable, or possibly profitable with AWS. However, it would require some techniques that Core doesn’t necessarily condone, so it might require some imagination to complete.

What you can do, however, is sign up with Microsoft Azure, under their free trial. This will allow you to hash for a longer period of time, with a much larger amount of cores.  In order to do this, you can find Ubuntu VPS on Azure (this should work in Debian as well) and you’ll use PuTTY (and the subsequent terminal) in the same way you’d use it in this article. Please note that you won’t need to worry about SSH keys with Azure. It works on a simple user/pass principal, so if you want to try your hand at this, just keep that in mind. You should be able to follow the tutorial and get to mining easily.

Maybe you’ll get lucky and make a little extra cash, you never know – there’s a lot of luck involved in mining (if you didn’t know that already).

Well, you should be to navigate around Linux enough to mine some coins. Let us know if you have any questions!

Jon Prints