Readers will learn how to launch an Amazon Web Services (AWS) Virtual Machine using the Ubuntu Server x64 AMI, connect to the server using SSH, and install the latest UniFi controller software.
Table of Contents
Amazon Web Services currently offers a "Free Tier" VM for twelve months for new users consisting of a t2.micro instance with 1 vCPU, 1GiB of memory and 30GiB of Storage with a variety of operating systems. When the Free Tier period expires, your VM will continue to operate as normal and the services will be billed on a monthly basis. For more details on pricing, see Amazon EC2 Pricing.
This article walks you through the process of launching an instance that meets the Free Tier eligibility criteria, but you are free to choose a larger instance type or a larger storage volume.
The Free Tier type typically provides enough resources to support small to medium UniFi deployments. You can always upgrade your Instance Type and Storage Volume in the future after you have launched your VM.
User Tip: When installing in a VM, you might encounter entropy issues. The fix is to install
Steps 1: Log In / Register and Launch an Instance
1.1. Log in or register a new AWS account at https://aws.amazon.com/
1.2. Choose the datacenter Region closest to where your UniFi devices will be deployed by using the link at the top-right of the screen, between your name and the Support link. This will ensure the lowest latency between your UniFi Controller and the devices it manages.
1.3. Choose EC2. From the AWS Console, under Computer.
1.4. Click Launch Instance, found under Create Instance to start the Create Instance Wizard.
Steps 2: Create the AWS Instance
2.1. Choose an Amazon Machine Image (AMI). For this article, we will be using Ubuntu, but you can select Debian if you prefer. Search for, and select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type. Notice it is labelled "Free tier eligible". Click Next.
2.2. Choose an Instance Type. Select the General purpose, t2.micro instance type. The t2.micro has 1 vCPU, 1GiB of memory, and is Free tier eligible. Click Next.
2.3. Configure Instance Details. Leave all settings as default. You may wish to check Enable termination protection - Protect against accidental termination, which makes sure you can't delete the instance by accident (this can be disabled in the future). Click Next.
2.4. Add Storage. AWS provides up to 30 GiB of EBS storage. Change the Size (GiB) of /dev/sda1 to 30GiB. Click Next.
ATTENTION: If storage isn't increased to 30GiB, there won't be enough storage for the database to operate properly.
2.5. Tag Instance. Tags are optional, and not required in our scenario. Click Next.
2.6. Configure Security Group. AWS uses Security Groups to define firewall rules.
- Assign a security group: Create a new security group
- Security group name: UniFi Controller
- Description: (describe your controller)
- Configure the rules as follows:
|Custom TCP Rule||TCP||8080||Anywhere 0.0.0.0/0|
|Custom TCP Rule||TCP||8443||Anywhere 0.0.0.0/0|
|Custom TCP Rule||TCP||8843||Anywhere 0.0.0.0/0|
|Custom TCP Rule||TCP||8880||Anywhere 0.0.0.0/0|
|Custom TCP Rule*||TCP||6789||Anywhere 0.0.0.0/0|
|Custom UDP Rule||UDP||3478||Anywhere 0.0.0.0/0|
|Custom UDP Rule**||UDP||5656-5699||Anywhere 0.0.0.0/0|
*This port is required for the mobile app speed test. The speed test was originally designed to be run locally so you may not get the best representation of throughput. If you don't plan on using the mobile speed test to your AWS instance, then you do not need to open this port.
**This is for remote EDU streaming only. If you are managing UAP-AC-EDU via a controller on AWS, then you also need to add 'stream.playback.url.type=inform' to system.properties. If you are not using UAP-AC-EDU, then you do not need to add open UDP range 5656-5699.
Security Tip: If you have a static WAN IP address for your local Internet connection, consider specifying a Source IP for the SSH Port 22 entry to ensure the server will only accept SSH connections from your IP address. This can be changed in the future from the console by modifying the Security Group.
2.7. Review Instance Launch. Use this page to review your configuration, and when ready, click Launch.
2.8. You will be prompted to select an existing key pair or create a new key pair. An AWS Key Pair allows you to securely connect to your AWS instance via SSH.
2.9. Provide a Key Pair name, and click Download Key Pair. Once you have saved the .pem file to a safe place on your computer, click Launch Instances.
2.10. You will now see a confirmation window saying your instances are now launching. Click View Instances to be taken to the list of instances.
Step 3: Assign an Elastic IP (Static Public IP)
While you wait for your new VM to launch, you can create a Static Public IP address to assign to the instance. Known as an Elastic IP in AWS, it is permanently allocated to your AWS account and can be moved between different instances. Unlike the regular Public IP, an Elastic IP address will persist even if the server is stopped.
3.1. Click on Elastic IPs on the left menu, under Network & Security.
3.2. Click Allocate New Address. In the confirmation dialog, select EIP used in: VPC, then click Yes, Allocate.
3.3. In the confirmation popup, take note of your new Elastic IP address, and click Close. For the rest of this article, replace any mention of <elastic-ip> in commands with this IP address.
3.4. Select your Elastic IP from the list, and click the Actions menu button. Click Associate Address.
3.5. In the Associate Address window, click the Instance text box, and choose your UniFi Instance. Click Associate.
NOTE: If you ever terminate your instance, remember to Release the Elastic IP as Elastic IP addresses that are not assigned to an instance are billed monthly by AWS.
Step 4: Connect Via SSH to the Instance
Using Windows (PuTTY)
If you are using a Windows computer, you can use PuTTY to connect to the server via SSH. You will need to convert the Key Pair (UniFiController.pem) file you created earlier from a .pem file to a .ppk file that is supported by PuTTY.
For detailed instructions on how to convert your .pem to a .ppk file and connect to the server using PuTTY on Windows, please read Amazon's PuTTY Setup Guide.
Using Mac OS X or Linux
If you are using a Linux or Mac OS X computer, you can use the built-in SSH client.
Open Terminal and follow these steps:
4.1. Edit permissions for the .pem file as required for SSH:
chmod 400 /location/to/UniFiController.pem
4.2. Connect to server using SSH and the .pem file, where <elastic-ip> is the Elastic IP Address configured previously:
ssh -i “/location/to/UniFiController.pem" ubuntu@<elastic-ip>
Step 5: Install the UniFi Controller
NOTES: The UniFi Controller does not support Java 9 yet. Amazon EC2 now installs with Java 9, so to ensure compatibility you must uninstall Java 9 and install Java 8 for the system to run properly.
Once you connect to the Server and are greeted with the Ubuntu Command Line Interface (CLI), do the following:
5.1. Add the Ubiquiti repository to /etc/apt/sources.list:
echo "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" | sudo tee -a /etc/apt/sources.list
5.2. Add the Ubiquiti GPG Key:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
5.3. Update the server's repository information:
sudo apt-get update
5.4. Install UniFi:
sudo apt-get install unifi
5.5. Disconnect from the server:
5.6. You may now close the Terminal or PuTTY window.
5.7. Open your browser and navigate to https://<elastic-ip>:8443/
5.8. Complete the UniFi Setup Wizard. You will need to skip Step 2: Discover as no devices will be available for adoption since the controller is not on the same subnet.
5.9. Your controller setup is now complete! You may now proceed to adopt your UniFi devices using Layer 3 Adoption.