# Easiest Way to Set Up a Shadowsocks Server

## VPS

You could use any service. Here I’m using Vultr’s Los Angeles server since that’s what works for me. Another really good hosting provider is Linode, but just for the purpose of what we’re doing today, Vultr saves us the trouble of upgrading the kernal.

Your operating system could be any Linux flavor. I’m going with Ubuntu 16.04 LTS x64.

TeddySun wrote a very nice script for setting up the four major flavors of Shadowsocks, and we are just going to use that:

wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh


It’s going to ask you which of the four Shadowsocks server (Python, R, Go, libev) you’d like to set up:

Which Shadowsocks server you'd select:
Please enter a number (default 1):


Next, you have to enter the password, and then the port you would like:

You choose = Shadowsocks-Go

(default port: 8989):

port = 8989

Press any key to start...or Press Ctrl+C to cancel


Here, for demo purpose, I pressed Enter and used the default settings. It doesn’t really matter what you put here as you can always come back and change the settings in /etc/shadowsocks-go/config.json later on.

Anyways, once that’s done, you’ll get a summary of your configuration, like this:

Congratulations, Shadowsocks-Go server install completed!


### Multiple Users

Edit the config.jsonfile, following this template:

{
"server":"0.0.0.0",
"local_port":1080,
},
"timeout":300,
"method":"aes-256-gcm",
"fast_open":true
}


### TCP BBR

What’s BBR, you might ask. Well, it’s

Bottleneck Bandwidth and Round-trip Time

To put it simply, it’s something extremely good for juicing the best speed out of your server that Google has made open-source. Sweet right?

Hey Linode users! Now it’s a good time to go and upgrade your kernal before moving on with the rest of the tutorial. Check out the last section of this post if you are not sure how to do that.

Ok, with the right kernal, you should now login using root user, and run the following commands:

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh
chmod +x bbr.sh
./bbr.sh


After that, you will be prompted to reboot your server. Do that with y+Enter.

Then, check if BBR is working normal:

sysctl net.ipv4.tcp_available_congestion_control


should return

net.ipv4.tcp_available_congestion_control = bbr cubic reno

sysctl net.ipv4.tcp_congestion_control


should return

net.ipv4.tcp_congestion_control = bbr

sysctl net.core.default_qdisc


should return

net.core.default_qdisc = fq

lsmod | grep bbr


should return something containing tcp_bbr in return. If not, run the following:

echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf


### Automatic restarts

This step is entirely optional, and unlike TCP BBR, it won’t dramatically increase your connection speed. Nevertheless, what I’m trying to do in this step is to set up a cron job that restarts the server every day at midnight to prevent it from getting sluggish.

First, create a bash script. I put it under /root/restart-ss.sh.

date


In the demo above, I was using Shadowsocks-Go. If you’ve gone with one of the other options, you would get an error with line 2, and you might have to just look around to find the right command for restarting your version of the shadowsocks server. For example, for Shadowsocks Python the command should be /etc/init.d/shadowsocks-python restart.

After that, just enter:

crontab -e


and add the following to the last line:

0 0 * * * bash /root/restart-ss.sh >> /root/cron.log


Perfect! Now run this to make sure our cron job is correctly set up and we’re good to go!

service cron restart


First, check your kernal information with:

uname -r


If it returns anything 4.9 and above, you are good to go. But for this instance 4.11+ actually works slightly better with BBR, so I’m still going to show you how kernal upgrade is done with Linode.

#### Install the Latest Kernal

Go to http://kernel.ubuntu.com/~kernel-ppa/mainline/ to locate the latest linux image. Hint: look for the one that has linux-image and generic in it.

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.5/linux-image-4.11.5-041105-generic_4.11.5-041105.201706141137_amd64.deb


2) Install kernal:

dpkg -i linux-image-4.11.5*.deb


3) Checking if installation is complete:

ls /boot/vmlinuz*


Incidentally, I didn’t purge the old kernal for safety concerns…

#### Configure GRUB

If you don’t have GRUB installed yet:

apt-get install linux-image-virtual grub2


1) Edit /etc/default/grub and change the parameters to the following:

GRUB_TIMEOUT = 10
GRUB_CMDLINE_LINUX =“console = ttyS0,19200n8”
GRUB_DISABLE_LINUX_UUID = true
GRUB_SERIAL_COMMAND =“serial --speed = 19200 --unit = 0 --word = 8 --parity = no --stop = 1”
GRUB_TERMINAL = serial


Keep everything else as it is.

2) Update GRUB

update-grub


3) Under the “Boot Settings” of your linode, change Kernal to “Grub 2”

reboot