Skip to content

Instantly share code, notes, and snippets.

@zhiguangwang
Last active April 29, 2024 12:56
Show Gist options
  • Save zhiguangwang/7018fbc0a38a5b663868 to your computer and use it in GitHub Desktop.
Save zhiguangwang/7018fbc0a38a5b663868 to your computer and use it in GitHub Desktop.
Installing and running shadowsocks on Ubuntu Server

Installing and running shadowsocks on Ubuntu Server

16.10 yakkety and above

  1. Install the the shadowsocks-libev package from apt repository.

     sudo apt update
     sudo apt install shadowsocks-libev
    
  2. Save ss.json as /etc/shadowsocks-libev/config.json.

  3. Replace server_port and password in ss.json with your own choices.

  4. Restart the shadowsocks-libev service.

     sudo systemctl restart shadowsocks-libev
     sudo systemctl status shadowsocks-libev
    

16.04 xenial

  1. Install shadowsocks with pip.

     sudo apt update
     sudo apt install python-pip
     sudo pip install shadowsocks
    
  2. Save ss.json under /etc/shadowsocks/.

  3. Replace server_port and password in ss.json with your own choices.

  4. Save ssserver.service under /usr/lib/systemd/system/

  5. Enable the systemd service.

     sudo systemctl enable ssserver
     sudo systemctl start ssserver
     sudo systemctl status ssserver
    

14.04 trusty

  1. Install shadowsocks with pip.

     sudo apt-get update
     sudo apt-get install python-pip
     sudo pip install shadowsocks
    
  2. Save ss.json, start.sh, stop.sh under /etc/shadowsocks/.

  3. Replace server_port and password in ss.json with your own choices.

  4. Put the following in /etc/rc.local to start ssserver upon server start.

     # Start shadowsocks server
     /etc/shadowsocks/start.sh
    

Use TCP BBR

This will enable TCP BBR congestion control algorithm to improve network bandwidth utilization (10x improvement is not uncommon).

Install linux kernel 4.9

Note: do this only if the distribution comes with a older kernel version.

URL=http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.9/linux-image-4.9.9-040909-generic_4.9.9-040909.201702090333_amd64.deb

wget $URL
sudo dpkg -i $(basename $URL)

sudo reboot

Enable TCP BBR

SYSCTL_CONF=/etc/sysctl.d/60-tcp-bbr.conf
echo "net.core.default_qdisc=fq" | sudo tee $SYSCTL_CONF
echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a $SYSCTL_CONF
sudo sysctl -p $SYSCTL_CONF

sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control
lsmod | grep bbr
{
"server": "0.0.0.0",
"server_port": "[port]",
"password": "[password]",
"timeout": 300,
"method": "xchacha20-ietf-poly1305",
"mode": "tcp_only",
"fast_open": true,
"nameserver": "8.8.8.8"
}
[Unit]
Description=Daemon to start shadowsocks server
Wants=network-online.target
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/ssserver -c /etc/shadowsocks/ss.json -qq
User=nobody
[Install]
WantedBy=multi-user.target
#!/bin/bash
sudo /usr/local/bin/ssserver -c /etc/shadowsocks/ss.json --user nobody -qq -d start
#!/bin/bash
sudo /usr/local/bin/ssserver -c /etc/shadowsocks/ss.json -d stop
@koistya
Copy link

koistya commented Jun 28, 2021

@pouriap
Copy link

pouriap commented Sep 23, 2022

When installing from Ubuntu 18.04 repository shadowsocks directory is not /usr/local/bin/ssserver also the option qq does not exist and gives an error. Building package from source as described here https://github.com/shadowsocks/shadowsocks-libev#build-deb-package-from-source did not work either.

@SimZhou
Copy link

SimZhou commented Mar 31, 2023

This tutorial runs a server, how can I run a client?

@kiawtf
Copy link

kiawtf commented Apr 29, 2024

how connect this shadowsocks to panel x-ui?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment