Up and running with SRCDS and Amazon EC2
Want to play the Mann vs Machine update with your friends? Don't want to get stuck waiting for some Valve official server to become available? Is your computer or internet just not fast enough to host the game locally?
If you answered yes to the above, then you've come to the right place. You can run a dedicated server by the hour using an Amazon EC2 instance and a Source Dedicated Server instance (graciously provided by yours truly). All you need to get started with Amazon Web Services a phone (any kind will do) and a credit card.
What You Will Need
- An Amazon.com account (We'll discuss how to set up AWS for this account later)
- A phone number. (Unsure. Amazon may have removed this requirement)
- A credit card. Prepaid cards probably won't work.
- PuTTY, if you're running Windows. You'll need both PuTTY and PuTTYgen. Direct download link
- Some basic knowledge of Linux/command line programs. Know when I say "type ./foo" you shouldn't type the word 'type' and know to hit enter afterwards. Super simple stuff.
- 45 to 60 minutes, depending on your reading speed and Linux-fu.
Running the machine I have listed costs $0.165 (16.5 United States Cents) per hour. This cost comes purely from Amazon; I do not take a portion for providing the server image that you will use. If you run the server 24/7 it will cost $125 per month, give or take. But don't freak out just yet! You can turn the server on and off as you wish, and when the server is off, it costs $0 per hour. I typically run my game servers 10 hours a day (4PM to 2AM) for a cost of $50 per month. If it's just you and a few friends playing 3 hours per night every night, it will cost about $15, which is much less than renting a 32-slot server from a gamehost.
EC2 Price list
Running a server costs real money. I am not responsible for any mistakes you may make (such as running 11 servers instead of 1) as a result of this guide. I strongly suggest reading through all of this guide before performing the actions detailed within. You have been warned.
Need help? Calm down. You read all of this guide once before executing the steps, right? Good.
If you need help, go to the post on Reddit, contact me there (mgway), or join our public Mumble server. I have a 9 to 5 (EST) job, so I probably definitely won't be on voice chat then.
I'm sure by now you're thinking "Wow, that is a lot of steps." But it really isn't that hard. All of the steps from "Signing up for Amazon Web Services" through "Configuring" only have to be performed once. Steps under the "Management" heading are the only steps that are used every time you wish to modify the state of the server. Not so daunting after all, is it?
Signing up for Amazon Web Services
Existing AWS users can skip this part
- Visit the Amazon Web Services page and click the big "Sign Up Now" button.
- Once you submit the form, go to the AWS EC2 page and select "Sign Up for Amazon EC2".
- Enter your credit card information and complete the signup process.
Configuring Amazon Web Services
After you finish signing up, you should end up at the AWS Console.
- Click on Key Pairs from the menu on the left.
- Click the "Create Key Pair" button and give the key pair a name.
- A .PEM file will automatically be downloaded.
- If you're on a Mac or running Linux, you can skip the following steps.
- Otherwise, open up PuTTYgen (you installed it already, right?)
- Click on the Conversions > Import key menubar option, and find the .PEM file that was downloaded earlier.
- Press the "Save private key" button, say Yes to the dialog, and find a folder and name for the file.
- You now have a PPK file to use in PuTTY.
Existing AWS users should start paying attention again
- In the AWS console, click on Security Groups on the left, then "Create Security Group".
- Give it a nice name and description, such as "TF2 group" and "Why is this description field required?".
- In the bottom pane of the console, click on the "Inbound tab".
- Choose "Custom TCP Rule", port range: 27000-27300 and leave the source the default "0.0.0.0/0".
- Click "add rule"", then create another rule that is "Custom UDP Rule" (Note the difference!), port range: 27000-27300 and the default source.
- After adding that rule, select SSH from the dropdown and add the rule. * Finally, click 'Apply Rule Changes' (if it's greyed out, make sure you clicked 'add rule' between each rule).
- Good job, you're just about halfway there!
Starting the Machine
- Click "EC2 Dashboard" on the left menu.
- Select "Classic Wizard" and continue.
- Under the "Community AMIs" tab, enter ami-7173c618 (note, it may take a while to show up, the search is brutally slow.), and click select when it appears.
- If it can't find the image, try this link which should pop up the launch dialog with the proper image already populated
- On the next page, change Instance Type to "High-CPU Medium (c1.medium, 1.7GiB)" and continue.
- Click continue on the Advanced Instance Options page and on the Storage Device Configuration page.
- You can enter a name on the tags page, but there's a 50-50 shot that the wizard will forget what name you put in and name it 'Empty', so don't be surprised when that happens.
- Choose the key pair you created earlier (should be selected if it's the only one).
- Highlight the TF2 security group you made earlier.
- Make sure everything looks right and launch!
- After you launch the instance, click on "elastic IPs" on the left.
- Click 'Allocate New Address' and leave the select box set to "EC2".
- Next, highlight the row (it may already be highlighted) and click "Associate Address".
- Select your instance from the dropdown and continue.
- Record the IP address somewhere (copy it to your clipboard or write it down if you prefer) as you'll need it in the next step.
- Open up PuTTY. in the hostname field, paste in the IP address you just recorded.
- Looking at the tree menu on the left, expand "SSH" and click on auth (the word Auth, not the + sign next to it).
- Click browse next to the only text field on the page, and locate the .PPK file you generated earlier (not the PEM file, the PPK that was outputted by PuTTYgen)
- Go back to "Session" at the top of the tree, enter "My TF2 Server" in the field under "Saved sessions" and click save.
- Click Open at the bottom.
- Type yes followed by an enter if a warning appears.
- The username is ubuntu
- You shouldn't need a password if you followed the above step.
OS X and Linux
- Open up a console window.
- Go to the directory with the PEM file.
- run 'ssh -i pemFileName.pem ubuntu@ip-address-from-earlier', replacing pemFileName.pem and ip-address-from-earlier as appropriate
- Wasn't that simple?
You're in the home stretch, baby.
- At the prompt, type ./configure.py
- Follow the on-screen instructions.
- If you did everything right, you should see a message stating that the configuration file was written. If it wasn't, or you made a mistake, simply re-run ./configure.py
- Run the server with ./start_type_servers , replacing 'type' with the server option you picked (mixed, mvm, normal)
- Congratulations, you've got your very own TF2 server now!
- ... But I suggest you do some more configuration before you start playing
Join the Game
- You can disconnect from the server (type exit) if you're still connected. Or not. Doesn't really matter.
- Run TF2 and open the developer console
- If you set a server password, type 'password InsertPasswordHere'
- Then, 'connect InsertIpHere:PortNumber' with the IP address you obtained earlier
- The first server is on port 27015. The second server is on port 27115
- Invite your friends to the server!
You don't need to perform these steps right now, just do it when you're ready and everyone has stopped playing on the server.
- To shut down the server (when you're done playing), go back to the AWS EC2 console.
- Click on "Instances"
- Highlight the running server
- Select "Stop" from the Instance Actions dropdown and confirm.
- Click on the Elastic IPs link on the left.
- You now have a choice. You are charged $0.005 (half a cent) per hour for having an IP address that is not attached to a running instance. This comes to $4/month.
- You can release the address by clicking the 'Release Address' button. However, releasing the address means that you'll need to allocate a new one the next time you start the server, and you're not guaranteed to get the same one next time. It can be annoying having to tell your friends a new IP address to connect to every time.
- If you don't want to release the IP address, don't do anything.
What fun would it be if you had to do all of that every time?
- To restart the server, highlight the server from the list of instances
- Select "Start" from the Instance Actions dropdown and confirm
- Click on the Elastic IPs link on the left
- If you released your address when you stopped the instance last time, allocate a new address and associate it, same as the first time.
- If you didn't release it, make sure the IP correctly associated with the instance (sometimes it doesn't happen automatically). If it isn't associated, associate it as you did the first time around.
- In a few minutes, you should be able to connect to your server via the IP address you allocated (or reattached).
That was a lot of steps, but hopefully they weren't too painful. If you have any suggestions, drop me an email at games at this domain dot net, or PM me on Reddit (there will proabably be a post about this shortly in r/tf2), username mgway.
~ Matt "oh!mg" Galloway