Shirone's Blog

Install and run shadowsocks on your server

Shadowsocks is a type of proxy server that uses an encrypted connection to redirect internet traffic. It is widely used in China to bypass the internet censorship where certain website or server are blocked e.g. Google, Twitter and network traffics are under censoring. I built up my first shadowsocks server in 2014, when I was 13 years old. Which is the first year that China started to block services from Google. That is also the first time I get in touch with linux. I literally starts from zero, copying and pasting the commands from guides on internet. That was a great memory. After I went to uni, which outside of China, I don’t need VPNs any more, but I’m still maintaining serval server in order to provide VPN services to my friends, as I believe that anyone has the right to freely access the internet.

I used to setting up shadowsocks on some cloud provides from China, like TenCent cloud or Ali Cloud (Since they are really cheap), and usually their network routing from China is optimized so you can enjoy a better connection quality. But also, there are many pre-installed monitoring applications you need to removed before you set up shadowsocks, or they will ban your account once they find out you are deploying VPN or there are abnormal traffic on your server. But yesterday one of my friend told me my shadowsocks is not working any more, and I find out that my TenCent cloud account finally got banned after 3 years. So I need to find a new cloud provider and sets up services again…

This article will show how I install and config shadowsocks server. This guide should works well with ubuntu or debian.

First, update apt package index and install snap. Note: If your server is running Ubuntu 16.04 LTS and above, Snap should be installed by default.

sudo apt update
sudo apt install snapd

Install snap core and shadowsocks-libev. You can also choose some other shadowsocks server applications, such as shadowsocks-rust, which is also available from but the configuration might be difference.

sudo snap install core
sudo snap install shadowsocks-libev

Edit the config file, create one if not exist. We will store the config file under the path /var/snap/shadowsocks-libev/common/ which is the default installed path from snap.

Here’s a sample config file. Usually I will use some port lover than 1000 because there are some rumors saying higher port might be detected and blocked more easily. But I don’t have any proofs or statistical data on this QAQ. Also, remember to modified the password to a stronger one.

{
    "server":["::0","0.0.0.0"],
    "server_port":123,
    "method":"chacha20-ietf-poly1305",
    "password":"WinnieThePoohDaisuki",
    "mode":"tcp_and_udp",
    "fast_open":false
}

Create a config file, register a service under debian to help us manage it.

sudo vim /etc/systemd/system/shadowsocks-server.service
[Unit]
Description=Shadowsocks-Libev Server
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/snap run shadowsocks-libev.ss-server -c /var/snap/shadowsocks-libev/common/config.json
Restart=on-failure
RestartSec=15

[Install]
WantedBy=multi-user.target

Start service

sudo systemctl start shadowsocks-server

Enable start at boot

sudo systemctl enable shadowsocks-server

Check service status

sudo systemctl status shadowsocks-server
● shadowsocks-server.service - Shadowsocks-Libev Server
     Loaded: loaded (/etc/systemd/system/shadowsocks-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-02-05 08:17:46 UTC; 3s ago
   Main PID: 2798 (ss-server)
      Tasks: 0 (limit: 544)
     Memory: 1.7M
        CPU: 54ms
     CGroup: /system.slice/shadowsocks-server.service
             ‣ 2798 /snap/shadowsocks-libev/508/bin/ss-server -c /var/snap/shadowsocks-libev/common/config.json

And now we are done! Enjoy your shadowsocks service!