Learn how to install ShadowsocksR (not Shadowsocks) server on Amazon EC2 Ubuntu instance (Free Tier) easily. Unlike the DigitalOcean guide I posted before, this one involves fewer commands and scripts.. hell yeah!
ShadowsocksR is a fork of the original Shadowsocks project, claimed to be superior in terms of security and stability.
Warning: Although this guide is intended to be 100% n00b friendly, there are chances you may face minor issues or errors during setup. Be prepared. Just write to mighil[at]orza.io or connect with me on WeChat: xonikk if you want me set it up for you for a small fee.
- Access to AWS console. (Requires one time credit/debit card verification)
- Read more about EC2 Free Tier.
- SSH client.
Step 1. Sign in to the AWS Console & Create an EC2 Instance
AWS may take you to the US region by default. It’s up to you choose the location.
1.1 Select EC2 in the Compute Section
Select Asian region (Tokyo or Singapore recommended) if you’re from China.
1.2 Click Launch Instance
Go on and read their Getting Started Guide if you’ve got enough time.
1.3 Select The Ubuntu Server 16.04 LTS
Ubuntu Server 16.04 LTS is Free Tier Eligible and that’s what we’re gonna use for this guide as well. Click Select and proceed to the next step.
1.4 Choose the Instance Type
Look for the t2.micro which is Free Tier eligible. Select it and Click Review and Launch.
1.5 Configure Security Group
Open the TCP ports you’re gonna use for ShadowsocksR. I’ve set Port Range from 8000–8083 for this guide. You can limit the source according to your preference. Click Review and Launch when you’re ready.
1.6 Create a New Key Pair
Create, download and save keypairname.pem file in a safe place.
Congrats on the 60% progress…n00bs, before jumping to the next big step, learn how to use PEM key on Mac. Windows users, you have to convert PEM file to PPK. Please read it here and come back to this article.
1.6.1 Copy The AWS Generated PEM File to a Safe Location
Here’s how to copy keypairname.pem to /Users/usrname/.ssh/ (hidden directory)
- Copy the keypairname.pem file.
- Open Finder, use the shortcut “Shift + Command + G” and type in /Users/usrname/.ssh/
- Paste the keypairname.pem file.
1.6.2 chmod 400 the PEM file
We have to set the right permissions for PEM file. Use the chmod command to make sure that your private key file isn’t publicly viewable. For example, if the name of your private key file is keypairname.pem, use the following command:
$ chmod 400 /Users/username/.ssh/keypairname.pem
Alright, it’s about time fellas! let’s dive into the Terminal/Putty.
1.6.3 Uncheck this Sucker in Terminal Preferences (Recommended)
Not necessary but since there are chances some users may get locale errors, it’s a best practice to uncheck this from Terminal Preferences. Check this thread in case you face locale issue.
Step 2. Connecting to The EC2 Instance
Let’s connect to your instance from Putty or Terminal:
$ ssh -i /Users/username/.ssh/keypairname.pem [email protected]
How to find your public IP
Check it from corresponding AWS EC2 webpage or run this command:
$ wget -qO- -t1 -T2 ipinfo.io/ip
Load your PPK and connect to the server as ubuntu user
Step 3. Switch User
Once you’re inside the EC2 instance. Switch to root user:
$ sudo su
Step 4. Run The ShadowsocksR Auto-Installer
Script by @teddysun
$ wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR.sh $ chmod +x shadowsocks-all.sh $ ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log
This installer is intuitive and will guide you setup ShadowsocksR on your instance.
Note: It contains installers for other Shadowsocks packages as well.
The installer will generate and display the final config. It displays Private IP (not public IP). So make sure you use Public IP within client apps. As I mentioned EARLIER, you can find your public IP within the corresponding AWS EC2 instance page or run this command to display the public IP:
$ wget -qO- -t1 -T2 ipinfo.io/ip
4.3 Commands to start | stop | restart | check status
$ /etc/init.d/shadowsocks-python start | stop | restart | status
$ /etc/init.d/shadowsocks-r start | stop | restart | status
$ /etc/init.d/shadowsocks-go start | stop | restart | status
$ /etc/init.d/shadowsocks-libev start | stop | restart | status
That’s it, congrats on the 100% progress. Write to mighil[at]orza.io or connect with me on WeChat if you want me set it up for you for a small fee.