Setting up a free Minecraft server in the cloud – part 2

In part 1 of this series I explained how to create a free Micro Linux server on Amazon EC2 suitable for running a small Minecraft server. In this article I will discuss how to connect to your new server, install Minecraft and configure it.

1. Connecting to your server for the first time

By now we have a server and a public IP address. So next we need to connect to it so we can install Minecraft etc. We will be using Secure Shell (SSH)  because, well, it’s secure. The best tool for SSH on Windows continues to be Putty. Download Putty from here and install it. While you are there make sure you also download PuttyGen as you are going to need it for the next step.

a. Converting your keypair from Amazon EC2 to Putty format

Amazon provides you a keypair in .pem format. Putty does not like that format so you need to use PuttyGen to convert the keypair into the .ppk format it likes.

Run PuttyGen and click the Load Button.

On the file selection dialogue make sure you select all files. Now select the .pem file you downloaded from Amazon EC2 for your server. PuttyGen should say it successfully imported the foreign key. Click save private key and save the .ppk fie somewhere.

Close PuttyGen.

b. Configure Putty to connect to your server

Start Putty. Enter your IP address. I have hidden mine.

In the left pane, select Connection | Data and enter the default user ID ec2-user

In the left pane select Connection | SSH | Auth and browse to the .ppk file you made in the previous step.

That’s all the configuration needed. You will probably want to save the config for next time. Go back to the main Session screen and click Save to save the session properties. Next time you start Putty you just need to load the appropriate settings.

c. Connect and login

To connect to your EC2 server. Click Open. In a few seconds you will get a nice new linux prompt like this (I have masked my IP addresses):

You are in and talking to your EC2 server. Remember it’s just a Linux box under the hood so all your standard Linux commands work. No GUI so if you don’t know any Linux commands now may be a good time to learn.

I will teach you the first few to get you started.

pwd prints the current working directory and tells you which folder (directory) you are in.
cd changes directory just like in DOS
cp  copies a file
mv moves or renames a file
ls -al lists all the files in the current folder with details
rm removes a file or files (careful with this one)
top shows what is running
cat displays the contents of a test file on the screen
nano a simple text editor
wget gets (download) a file from a web site using a URL
man <command> explains how to use a command and what it does (manual pages)

2. Download Minecraft server

From your linux prompt type:

mkdir MinecraftServer
cd MinecraftServer
wget http://www.minecraft.net/download/minecraft_server.jar

This will create a new folder and copy the latest version of the Minecraft server to it.

3. Start Minecraft server 

Type the following command:

sudo java -Xmx512M -Xms512M -jar minecraft_server.jar nogui

This command invokes the Java VM, sets the minimum and maximum memory to use and starts the Minecraft server. Notice I have used 512M as the memory size rather than the suggested 1024M on the Minecraft sites. This is because we are running on a micro Linix server and we only have 612MB in total. If you want more memory you are going to have to upgrade to a larger EC2 but you are also going to have to pay for it.

The first time the server starts it creates “spawn areas”. This can take some time. Just let it go. It sometimes seems to get stuck – it isn’t. Stop screen watching  and get a coffee.

Once the server is finished you can enter commands as “Admin”. Type help to display this screen:

To stop your server type stop.

4. Connect from Minecraft client using IP address and test

Once the server has completed creating its spawn areas you can connect to it from your Minecraft client. Just enter the IP address that Amazon has assigned your server. In a few seconds you should be connected to your very own brand new Minecraft server.

Remember this is a free Minecraft server in the cloud running on the smallest virtual server that money cannot buy. It’s not going to support 50 simultaneous connections. It will quite happily support you and one or two Minecraft buddies. If you want less lag and more performance, you will need to pay for a larger EC2 server. 

In part 3 I explain how to upgrade your server to a Small instance and still save money.

48 comments to Setting up a free Minecraft server in the cloud – part 2

  • Thomas

    Bukkit would make a great topic for those looking to host MC servers. There’s hundreds of great plugins that give you advanced logging, user-based and group-based permissions, added gameplay features and much more.

    Unfortunately, the server load is pretty substantial. It’s probably not something that you could throw on an Amazon EC2 micro instance (found this out over the weekend personally).

    One thing I would like to mention that has helped me in my Minecraft server hosting…Dynamic DNS.
    Ben, have you looked into a service like DynDNS? I find giving people an actual hostname, as opposed to an IP address, works much better in helping people remember where your server is. And it also follows the “free” topic – you get two free dynamic DNS hostnames that will redirect to a changing IP address. It probably doesn’t apply as much to an Amazon instance but for those looking to host at home, it’s extremely useful.

    Thanks again for the articles. As per my previous comment, after trying to install Java in a Ubuntu AWS AMI for hours (of which there is a fatal bug that Ubuntu has been trying to fix for over a year…), I went with the Amazon Linux AMI and got Bukkit up and running within 10 minutes.

  • caleb cohoon

    Thanks so much for this tutorial! I just got my first minecraft server up and running. 🙂 Thanks!

  • Ziore

    I SRSLY LOVE YOU RIGHT NOW,
    THANK YOU :3
    Server up and running with 0% lag

  • jeremiah

    will my server keep running if i close putty?
    or will it shut down? cause i closed putty and a few seconds later i was disconnected from the server. how do i close it without this happening>? i dont want to run putty every time i start my comp

    • Ben

      Jeremiah

      Yes, the minecraft server will close down as soon as you close Putty. Try to install screen. It allows jobs to run in the background even after you close putty. To install run sudo yum install screen. Then type man screen to learn how to use it.

      Good luck
      Ben

  • jeremiah

    Thanks Ben, that was a small problem compared to the IMMENSE LAG I was getting cause I didnt realize there were regional server options in AWS Management console. Now that I have a server nearest my region it is smooth as butter.
    Thank you for this article it is awesome.
    One thing though I know i did something wrong setting up my second one b/c its not asking for a passphrase when I first connect to the ec2 linux box. The first one i set up wanted a passphrase before i could do anything. I set up the keypair with putty and all, should I be concerned? Easy way to fix without starting a whole new instance? Seems like it could be like pinged and gotten right into, I dunno maybe a non-issue cause whats the worst that can happen? they cant get into my AWS or my minecraft accounts with control over that right? Oh well thanks for everything

  • Owen Deakin

    I had a my book live with feature manager installed (where to get it http://highlevelbits.free.fr/index.php?option=com_content&view=article&id=606&Itemid=81&lang=en) and looked at this tutorial. then follow step 2 Then because it used linux like this i used putty again and installed java (how to install java http://www.wikihow.com/Install-Java-on-Linux ) ( follow option Ubuntu OpenJDK Method Using a Console then on step 2 use the server option then follow onscreen instructions) then you can do step 3 it takes a while (this is when i am typing this). If you type in the ip address of the mybooklive on your network (while you are on the network) after it has finished you will join. if you want other people to join you will have to port foward yourself. Use port 25565 when port fowarding unless you changed it then your the port you chosed.

  • Mike

    This article was great and I was up and running last night. Since I’m not using screen, of course, it shut down when I closed putty. Today, when I issue the ‘sudo java -Xmx512M…’ command, it tells me I don’t have enough RAM and maybe it’s running on the port already. I’ve rebooted the instance, but I still get the message. I changed the 512 to 256 and still get the message. What have I missed?

    • Mike

      Apparently I “did something”, lol. Since we hadn’t built anything in the world yet, I just deleted the minecraft directory and repeated steps 2&3 above. It was okay, thereafter. I just used vi to make my edits to things like server.properties and the white-list and there were no issues.

  • I’ve been looking for a way for me and a couple of friends to play Minecraft together on the cheap. Thanks for putting this together. I’ll be trying this week to get this together.

  • Peter

    Many, many thanks. I’ve a twelve year old wanting a Minecraft server, your explanation was great. Now she’s asking about configurations, so I’m looking forward to a future article. In the mean time I found a couple of things that might help others;

    1. If you are on Mac, like me, you won’t have Putty. Instead I used FireSSH a Firefox plugin. It seemed simpler to use and worked well. (If people aren’t familiar with Putty its probably an easier option on the PC)

    2. Found a page about Screen and Minecraft and worked out starting your setup under screen was:

    > sudo screen -dmS minecraft java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui

    Breaking back in was: sudo screen -r minecraft
    and stopping server : stop

    Details here: http://www.minecraftforum.net/topic/33616-running-minecraft-in-a-screen-session/

  • Andy

    How did you get firessh to work. I’m working really hard at it right now.

    a

  • Dan

    hey I had a question because I’m new to all this. About screen and the server, is the server running all the time on the cloud? like say my computer is off would other people be able to connect to it?

    • Ben

      Dan
      If you use screen, then Minecraft will continue to run in the background. You can then disconnect from your server shut your pc down and others can still connect. That way you can have a 24/7 server. There are a couple of good tutorials around about how to install and use screen.
      Cheers
      Ben

  • Matt

    If I wanted to port over a server I was already running on my home computer to this new server, how would I go about that? Is it doable?

    • Ben

      Matt, Yes it is doable. You need to copy the world folder across using WinSCP or Cyberduck. Best to make a backup copy of the old one first. Ben

  • Kevin Pierce

    Thank you so much for the helpful guide and for additional guidance concerning the use of PuTTY and the screen command – works great!

  • Carlos

    Ben –

    A huge thank you from Texas. My 11 year old boy has been asking to do this and we were exploring using a DMZ for a computer in our home network, and that was a real pain. This solution is fantastic and the Amazon Cloud is amazing. It’s very rare that people put such greatly detailed instructions on the web, but newbies like me really appreciate it.

    Best Regards,
    Carlos

  • Owen Hutchinson

    Thanks from Perth, my boys and a couple of their mates are jumping out of their skin now they have their own Server. Great detailed instructions.

    Many thanks Owen.

  • Dave McClintock

    Hi -thanks for this tutorial, however I am not a linux expert, and would like to try this on Windows.
    I have an AWS EC2 instance up and running, and can access it with RDP. However it keeps stopping all downloads from the internet with unhelpful error message “cannot download file”. I changed IE security to allow me to at least get to the download page and it attempts. It almost seems like there is no disk/storage on my instance – Do I have to configure that manually?
    Anyone have experience with this?
    Thanks,
    Dave (Santa Barbara, CA)

  • Justin Hough

    My 11 year old wanted a server for the last year. I tried CloudCube’s cheapest server but it was not powerful enough. This is great. Your instructions were excellant. I bet I will be creating the charagable server in a few months. I love the batch commands to manage it. Keep up the great work!

  • JK

    This is great stuff, thank you for making it simple.

    What are the limits of this little free server? Right now it seems to be doing fine with two users, though the minecraft server is complaining a bit.

    • Two users is about it for the micro instance. To handle more you have to upgrade to a paid small server.

      • JK

        They are going to try with three players tonight, we’ll see!

        Given that the actual uptime needed is really not that great, isn’t there a way of triggering a paid instance to come online as an on-demand service? Maybe some kind of listener daemon on a free instance which fires up the paid instance in response to a minecraft client connection, and then acts as a proxy. And once the last user leaves, it could wait ten mins and then stop the paid instance.

        Would that work? What would be a good language to implement it, Python?

    • alex

      The limit is 5 players for every 512 MB you run the server on

  • Cooper

    I am working with my son, Cooper, to create a Minecraft Server. We have set up the Amazon EC2 server, but now need to do what you outline in Part 2. However, we are on a Mac so we’re not sure how to proceed. We saw the comment from Peter in November 2011 who recommended FireSSH for Firefox. We have downloaded that, but are now not sure how to proceed.

    Can you help us?

    Thanks,
    Cooper and his mom, Rebecca
    Austin

    • Daryl

      Hi Rebecca,

      on a mac it is just as easy to use the built in UNIX ssh support:

      1) save the .pem file somewhere – mine is in a folder on my desktop so its “full pathname” is /Users/daryl/Desktop/Minecraft/My.pem
      2) run Terminal from your Applications/Utilities folder
      3) the .pem must be readable only by you so type:

      chmod go-rwx full pathname of .pem file

      4) Now run ssh. Type:

      ssh -v -i full pathname of .pem file ec2-user@IP address of your server

      so I do something like: ssh -v -i /Users/daryl/Desktop/Minecraft/My.pem ec2-user@MYMACHINEIP.eu-west-1.compute.amazonaws.com

      A nice feature of Terminal is that if you type “ssh -v -i ” and then drag the .pem file icon to the terminal window the full pathname will be inserted for you.

      Good luck
      Daryl

  • Tom Way

    Wow. Thank you thank you thank you. Just worked through the steps and got the Minecraft server setup that my 11 year old son Ned has been asking for for months. We’ve tried hosting one on a surplus Windows box at my office and on a castoff Linux server at a friend’s house, but firewall issues were always cumbersome, if not insurmountable. This worked so well! Thank you so much!

  • Adam Short

    Thanks for a great article, got the server up fine with no problems, however is there a way that I can access where the server is running from as I’d like to be able to play with my custom world that I built in single player?

  • Ryan

    I appreciate the tutorial. I was looking for a nice easy way to host a 2 player server outside of my laptop and this worked perfectly.

    Will keeping a micro-instanced server running 24/7 incur any penalties in this free year?

  • The way to run the Minecraft server and leave it running after you log out is:

    nohup sudo java -Xmx512M -Xms512M -jar minecraft_server.jar nogui >minecraft.log 2>&1 &

    You’ll note that in the middle of all that is the same command that Newtown Nerd told you to use to run the server. The “nohup” at the beginning says don’t shut down this program when I log out. The “&” at the end says run the Minecraft server in the background so I can type more commands while Minecraft is running. Commands like “exit”.

    Write down the number that is output after you press enter. This is very important. You need it to stop the server. The number is the “process ID” of the server you just started.

    If you want to stop the server, you have to type:

    kill -9 process-ID-of-minecraft-server

    There are other ways to stop it, but I need to test the steps before I write it out, and I haven’t built my server yet, so I can’t test it. In the meantime, you can ask your Linux guru friends how to shut down the server if you don’t know the process ID of your Minecraft server.

  • Elijah

    okay i have two questions, every time i shut down putty and i want to start it back i have to type in “sudo java -Xmx512M -Xms512M -jar minecraft_server.jar nogui” this to me is a real pain. How would i go about saving it to where it will immediately when i start it up. Also is there any way for me to be able to load up a map that i have already made into this server. Or if there is no way, how can i completely get a new world.

  • Michael

    I have my world up and running thanks to you but I have a question. How do I use my singleplayer world from my own computer on the server? I have already uploaded it to google docs in case I will need to download it onto the server.

  • Constance

    Hi guys, I have a problem :S. As of now I’m running my server from the mac side, and I’m currently using AWS. I basically have everything up and running until I have to use putty. Reading the comments, I tried typing:

    chmod go-rwx full pathname of .pem file

    ssh -v -i full pathname of .pem file ec2-user@IP address of your server

    into terminal (subbing in the roots native to my own computer of course) but I get a message that: The Authenticity of the Host: (ip address of the ec2) cannot be established, and what follows that is a bunch of debug1 lines where the computer tried to find “public keys”. Eventually the computer shrugs and says: “No such file or directory”

    I’m really not very familiar with all this stuff 🙁 anyone knows what’s to be done next?

    • I got past this bit on a Mac. Go to your AWS console, to EC2 and your list of instances. Right click on your instance and hit ‘connect’. There are instructions there to use an SSH console. Follow those instructions in your terminal window (I use iTerm).
      Put the key file in the directory you are going to run the SSH command from.

  • Rexroth

    Thank you for your fantastic tutorial!
    I have a question: what if you want to generate a new minecraft world to replace the old one? Is there a command line for that?

    • alex

      You need to go into the server.properties file in your server folder and change where it says “level-name=” after the equals say the name of the new world you want, but it has to be different from your current world name. After you’ve done that, you have to restart your server and it should start generating the new world. It may take a while depending on your computer but when it’s done it’ll start like normal with the new world. The good thing is that you’ll still have the old world if you want to change and if you want to change, all you have to do is change the “level-name=” back to the name of your old world.

    • alex

      You have to go into the server.properties file and change where it says “level-name=”,after the equals say the name of the new world you want, but it has to be different from your current world name. Then you have to restart your server and it should generate a new world for you.

  • Thanks..now my boy has his own little minecraft server.

    Much appreciated!

  • Roberto

    Thanks! Thank-you very much for this tutorial, now i have a question, i have a minecraft world in my computer from the old local server, can i upload that world to the ec2 server? If so, how?

  • Mike

    Quick question: I am trying to edit the server.properties file using Nano (nice suggestion!) but it seems that the files are all owned by root and so I don’t have permission to edit them even though I can see them. Any suggestions on how to go about changing the permissions on them so that I can edit them?

  • Hey Newtown Nerd, thanks for the excellent tutorial.
    I seem to be having a different problem to everyone else. I got it installed and running but I can’t connect to it. I can’t even ping the elastic IP address. I’m reading a bunch of stuff about how to enable ping which I haven’t mastered yet.

    Did anyone have trouble connecting? I’m entering the elastic IP address right into the server address box in Minecraft client.

    Thanks!

  • Tried all sorts of things to get around my problem but nothing. I do everything exactly as explained but I just can’t get minecraft clients to connect. They just time out. I can connect to other public servers.
    I’m about to give up on the whole thing which is very disappointing to my son!

    I gave up on trying to ping the server, I don’t think I need to since I can SSH that won’t prove anything.

    Thinking I’ll repurpose my free server to be a little web server if I can’t get this sorted.

    Any ideas appreciated …Thanks!

  • Paul B

    @caroline, I discovered the elastic IP dis-associates itself when you shutdown the server, so you have to go and re-associate it. maybe that’s it?

  • how do you turn on your physycal minecraft server?
    i would REALLY like to know!!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>