How to run a Minecraft server on Amazon EC2
I originally published this article on minecraftforum.net. This draft is revised for 2014, since Amazon updated their offerings. It’s really out of date now but it’s interesting as the first comprehensive guide to doing this.
This is an easy way to get a Minecraft server running 24 hours a day. It may not be the most cost-effective method - watch your Amazon bills! - but it’s a great way to get familiar with EC2.
You will need some basic Linux ability for this guide.
Server facts
- The server we’ll use has 2GB memory
- You get 8GB disk on Elastic Block Storage (EBS)
- The Operating System we’ll use is ‘Amazon Linux’ (their own distro)
- Comes with Java 7 ready to go.
Let’s create a server
This is really straightforward.
- Sign up for an account at http://aws.amazon.com/ and give them a payment method. There is no fixed charge for EC2 servers: you pay for what you use. - If you’re sure you want to keep the server for a long time, a Reserved instance works out way cheaper.
- Navigate to the Amazon EC2 tab. This may take a minute or two to become active if you’ve just signed up. You will see that you have no instances, and the page will prompt you to Launch Instance.
- Hit the Launch Instance button to see a list of the possible server types. We’re going to choose the first option on the list, Amazon Linux AMI (HVM). - This image uses EBS, which is independent storage. The alternative is ‘Instance Store’ which is less flexible.
- Now we Choose an Instance Type: we want a t2.small. To move on, hit
Next: Configure Instance Details
. - Micro instances are cheap, but they have some pretty crazy CPU throttling. Not recommended. - On the Configure Instance Details page, we don’t need to mess with anything. Hit
Next: Add Storage
. - Under Volume Type, you can choose between Magnetic and General Purpose (SSD). Storage is pretty cheap (less than a dollar per month for 8GB) so go for General Purpose (SSD). Now
Next: Tag instance
. - Notice you can choose the space available here. Default 8GB is fine. - Tag instance: we can ignore this since we only have one server to worry about. Hit
Next: Configure Security Group
. - Configure Security Group: This is your firewall policy. It’s a set of Rules which dictate who is allowed to connect to the server. We need to open a Minecraft port to allow players to connect.
1. Let’s Create a new security group and go with:
- Security group name: minecraft-security
- Description: Ports for Minecraft
- You’ll see an existing Rule for SSH. We need a new one for Minecraft. Hit
Add Rule
and go with:
- You’ll see an existing Rule for SSH. We need a new one for Minecraft. Hit
- Custom TCP Rule
- Port Range: 25565
- Source: Anywhere
- If you want to run with a non-standard port (to improve security), use that port here instead of 25565.
- Finally
Review and Launch
.
- Finally
- If you want to run with a non-standard port (to improve security), use that port here instead of 25565.
- The Review Instance Launch panel will summarise our options and warn us about security, since we’re not limiting where SSH connections come from. This is fine for now: hit
Launch
. - Now you’ll get prompted for a Key pair, which you’ll use to log into EC2 servers. On the dropdown, Create a new key pair and call it something sensible like
my-key
. FinallyDownload Key Pair
. - You’ll download a file with the extension .pem, e.g.my-key.pem
. This is what you’ll use to log in later. HitLaunch instances
and thenView instances
. - Keys are important, because EC2 servers do not use passwords to log in! Instead you have a private key file stored on your local computer, which is used to authenticate.
You should now see your running instance listed - congratulations, you just created a server! Click on it to get details in the lower pane.
Observe your new Public IP: Players will need this to connect.
Let’s log in
I’m going to assume you’re using PuTTY on Windows.
- Open PuttyGen. We’re going to convert the private key that Amazon gave us (.pem) into a Putty key (.ppk).
- Hit
Load
, select the .pem key - you might need to filter ‘All Files’ in the dialog - and then hitSave private key
to save it as a .ppk file. - Now you can close PuttyGen. - Open Putty - we’re going to configure a new Session. In the Host Name, enter
ec2-user@your-Public-IP
. e.g.ec2-user@12.13.14.15
- Next look in SSH -> Auth. Use the
Browse
button to select your new .ppk file. - Now back to the Session tab - give your session a name in the ‘Saved Sessions’ text area (e.g. ‘EC2 minecraft’) and hit
Save
. - Finally hit
Open
to try and connect. - You will need to hitYes
when prompted to confirm you’re connecting to a new server. - Putty will automatically try to log in asec2-user
(because you put the user prefix on the URL). Then it will present the key file which means no password is needed. You should be in! - If for some reason the automatic login doesn’t work, enter your username asec2-user
.
At this point you have everything you need - a working server and shell access.
What now?
You should be logged into the ec2-user
home directory, with 8GB of storage to play with.
First up, this is a good time to update the packages on your server with sudo yum -y update
.
To verify java is working, try java -version
.
Go ahead and install Minecraft in this directory. There are many other guides to help you at this point. At minimum you need to wget
the server jar and run it with java -jar some-minecraft.jar
.
If you’re not afraid of more techie stuff, I wrote a followup article on how to get started with a tool called Minecraft Server Manager.
Things to know
You never log in as root
, but always ec2-user
. If you need to run something as root, prefix the command with sudo
. e.g. sudo yum install foo
to install the ‘foo’ utility.