Set up Your Own Shadowsocks Server On Debian, Ubuntu, CentOS

Shadowsocks is an open source socks5 proxy that can be used to bypass firewall and unblock websites. Originally developed by a Chinese called clowwindy on Github, now the application has been implemented in all kinds of programming languages such as C, C++, Go, Python and the like. This Tutorial will guide you through setting up your own Shadowsocks server and how to use it on your desktop computer, android and iOS. I assume you already have access to a VPS or dedicated server.

Update: The Python implementation of Shadowsocks hasn’t been updated for a long time. It is recommended that you use the C implementation: Shadowsocks-Libev.

Shadowsocks VS VPN

As you may already know, you can use VPN (Virtual Private Network) to bypass firewall and protect your anonymity on the web. Do you need another software like shadowsocks to do the same? One thing you can find is that When you are using VPN, all your Internet traffic is routed through VPN. Because VPN servers are usually located outside your country, this can slow down your Internet speed especially when you are visiting websites inside your country.

Shadowsocks comes to the rescue! Besides a global proxy setting, shadowsocks can also be setup in a way that some of your applications go through shadowsocks and other applications go through normal traffic. For example, you can use Google Chrome to bypass firewall, visit Google, Facebook, YouTube and use Firefox to visit sites that isn’t blocked in your area.

By the way, shadowsocks client will automatically reconnect to shadowsocks server if there’s a disconnect. Although you can configure VPN client to do the same, but that will take extra work.

Setting Up Shadowsocks on Your Server

There are many ways to install shadowsocks on Linux server, but I will show you the easiest way. First, install python pip and then use pip to install shadowsocks. m2crypto will make encryption a little faster.

Debian /Ubuntu

sudo apt-get install python-pip python-m2crypto
sudo pip install shadowsocks

CentOS/RHEL

sudo yum install m2crypto python-setuptools
sudo easy_install pip
sudo pip install shadowsocks

Create a configuration file with a command line text editor like nano.

sudo nano /etc/shadowsocks.json

Put the following text into the file.

{
"server":"your_server_ip",
"server_port":8000,
"local_port":1080,
"password":"your_passwd",
"timeout":600,
"method":"aes-256-cfb"
}

Explanation of each field:

  • server:  your hostname or server IP (IPv4/IPv6).
  • server_port:  server port number.
  • local_port:  local port number.
  • password:  a password used to encrypt transfer.
  • timeout:  connections timeout in seconds.
  • method:  encryption method, “bf-cfb”, “aes-256-cfb”, “des-cfb”, “rc4”, etc. Default is table, which is not secure. “aes-256-cfb” is recommended.

Replace the green text with your info. Save and close the file, then start shadowsocks server.

sudo ssserver -c /etc/shadowsocks.json -d start

To stop shadowsocks server:

sudo ssserver -d stop

Restart Shadowsocks server:

sudo ssserver -c /etc/shadowsocks.json -d restart

Check Shadowsocks log

less /var/log/shadowsocks.log

If necessary, you can always manually download the python version from python.org.

You may need to allow traffic through your Shadowsocks server port in iptables firewall by running command: sudo iptables -I INPUT -p tcp --dport 8000 -j ACCEPT

Auto Start on System Boot

If you want shadowsocks server to automatically start on system boot, then edit /etc/rc.local file

sudo vi /etc/rc.local

Add the following line to the file above exit 0 line

/usr/bin/python /usr/local/bin/ssserver -c /etc/shadowsocks.json -d start

Install and Configure Shadowsocks Client on Desktop Linux

Ubuntu users install it from PPA

sudo add-apt-repository ppa:hzwhuang/ss-qt5

sudo apt-get update

sudo apt-get install shadowsocks-qt5

Fedora/RHEL users can install it from Copr Repository

sudo dnf copr enable librehat/shadowsocks

sudo dnf update

sudo dnf install shadowsocks-qt5

There’s a shadowsocks-qt5 package in AUR repository, so Arch users can use yaourt package manager to install it.

sudo yaourt -S shadowsocks-qt5

Mac and Windows users refer to this page for downloading shadowsocks client.

Configure Shadowsocks Client

Once downloaded and installed on your computer, open it. And right click on the blank background, choose add and then manually to manually add a profile.

ss-client

In the Profile Editor Window, give your profile a name. Then enter the following information as specified in the /etc/shadowsocks.json file on your server. Once it’s done, click OK button to save the profile.

ss2

Back in the connection manager window, choose you newly added profile and click connect on the upper-left corner.

ss3

Now your shadowsocks client is connected to your server. Next we will tell Firefox and chrome to use your shadowsocks client.

Configure Firefox And Google Chrome to Use Shadowsocks

Open up Firefox, and in the menu bar, choose Edit and then Preferences. And then click the Advanced tab. choose network and then settings.

firefox-proxy

In the connection settings window, choose manual proxy configuration and then on the socks host field enter 127.0.0.1, enter 1080 in the port field. Be sure to choose socks v5 as the socks type. And finally click the OK button.

firefox-proxy2

Now your firefox can visit google, youtube and other blocked sites!

For Google Chrome users, there’s a plugin called SwitchyOmega that you can install on Chrome. Once installed the plugin, open its options page, add a profile. Then edit your profile as follows. Save the profile and you are done. Now you can visit those blocked sites!

SwitchyOmega

Install Shadowsocks on Android and iOS

Android client download

iOS client download link

Speed Optimization

The most important factor here is your server location and Internet speed of your ISP.  For example, I live in China and have shadowsocks server located in the United States. Although my server has fast connection to Youtube.com, but because the speed between me and my server is slow, so the overall speed between me and Youtube.com is slow.

The solution is that I rented another VPS located in Hong Kong and built a shadowsocks server on it. The speed between me and the server in HK is fast and HK server has fast connection to Youtube.com, so I can now view Youtube videos in 720p without hiccups.

Rate this tutorial
[Total: 97 Average: 3.8]

6 Responses to “Set up Your Own Shadowsocks Server On Debian, Ubuntu, CentOS

  • Tips for China
    3 weeks ago

    You should be able to get decent speed for YouTube from your USA server if you install a TCP congestion avoidance algorithm such as serverspeeder or bbr. Here is a tutorial showing how to set up a shadowsocks server with bbr.

    https://www.tipsforchina.com/how-to-setup-a-fast-shadowsocks-server-on-vultr-vps-the-easy-way.html

  • Vahid Afshari
    2 months ago

    hi
    when i use this command:

    sudo pip install shadowsocks

    got this error:

    Traceback (most recent call last):
    File “/usr/bin/pip”, line 9, in
    load_entry_point(‘pip==18.0’, ‘console_scripts’, ‘pip’)()
    File “/usr/lib/python2.6/site-packages/pkg_resources.py”, line 299, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
    File “/usr/lib/python2.6/site-packages/pkg_resources.py”, line 2229, in load_entry_point
    return ep.load()
    File “/usr/lib/python2.6/site-packages/pkg_resources.py”, line 1948, in load
    entry = __import__(self.module_name, globals(),globals(), [‘__name__’])
    File “/usr/lib/python2.6/site-packages/pip-18.0-py2.6.egg/pip/_internal/__init__.py”, line 42, in
    from pip._internal import cmdoptions
    File “/usr/lib/python2.6/site-packages/pip-18.0-py2.6.egg/pip/_internal/cmdoptions.py”, line 16, in
    from pip._internal.index import (
    File “/usr/lib/python2.6/site-packages/pip-18.0-py2.6.egg/pip/_internal/index.py”, line 536
    {str(c.version) for c in all_candidates},
    ^

  • Hi, Use this command to get the last version of shadowsocks
    pip install -U git+https://github.com/shadowsocks/shadowsocks.git@master

  • Use this command

    pip install -U git+https://github.com/shadowsocks/shadowsocks.git@master
    
  • > Android client download

    > Goolge Play

    Typo, that should be Google

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here