Are you configuring a completely fresh Ubuntu 12.04 server, in particular by using Amazon Web Services EC2 servers? Well here is some good flow for setting it up in a somewhat principled manner. This info is compiled from here and here and here, as well as my own notes from setting up an earlier Ubuntu box. Feel free to contact me (check the about)!
Considering we are already super user, start with the basics:
sudo apt-get update
sudo apt-get upgrade
Install build essential to get some good libraries for compiling other libraries:
sudo apt-get install build-essential
Amazon Web Services already locks down specific ports, and yes it requires that key-pair file, but that SSH port will still gets pinged.
So now a security daemon (pun intended) that monitors and blocks suspicious login attempts:
apt-get install fail2ban