Skip to content

Instantly share code, notes, and snippets.

@x-magic
Created July 6, 2016 11:25
Show Gist options
  • Save x-magic/581292b140566c64bd4332911540b85f to your computer and use it in GitHub Desktop.
Save x-magic/581292b140566c64bd4332911540b85f to your computer and use it in GitHub Desktop.
Automated installation script to install Shadowsocks on Debian Jessie server (perfect for DigitalOcean droplet)
#!/bin/bash
# A script that automates Shadowsocks on a Debian Jessie server
# Perfect for and tested on DigitalOcean 512MB ($5/month) Debian Jessie x64 droplet, as of July 2016
# Since this is modifying systemd servie script so it won't work on Debian Wheezy
# Disable nfs and rpcbind service (this is just for DigitalOcean Debian distros since these services are useless!)
systemctl stop nfs-common > /dev/null 2>&1
systemctl disable nfs-common > /dev/null 2>&1
systemctl stop nfs-common > /dev/null 2>&1
systemctl stop rpcbind > /dev/null 2>&1
systemctl disable rpcbind > /dev/null 2>&1
systemctl stop rpcbind > /dev/null 2>&1
netstat -lnput
echo -e "\n\nPlease confirm that sshd is the only service that is listening to a port. \n\n"
read -p "Press [Enter] key to start installing Shadowsocks..."
# Add Shadowsocks repo and install Shadowsocks-libev
echo "deb http://shadowsocks.org/debian wheezy main" > /etc/apt/sources.list.d/shadowsocks.list
wget -O- http://shadowsocks.org/debian/1D27208A.gpg | apt-key add -
apt-get update && apt-get dist-upgrade -y
apt-get install shadowsocks-libev -y
# Replace original configuration file with this new version
# Change following configuration file with your desired server port and password
cat << EOF > /etc/shadowsocks-libev/config.json
{
"server":["[::0]", "0.0.0.0"],
"server_port":8388,
"local_port":1080,
"password":"password",
"timeout":60,
"method":"aes-256-cfb"
}
EOF
# Enable UDP relaying, then restart Shadowsocks service
sed -i 's/$CONFFILE/$CONFFILE -u/g' /lib/systemd/system/shadowsocks-libev.service
systemctl daemon-reload
systemctl restart shadowsocks-libev.service > /dev/null 2>&1
systemctl status shadowsocks-libev.service > /dev/null 2>&1
# That's it!
netstat -lnput
echo -e "\n\nPlease check if ss-server is listening to both tcp and udp ports.\n\n"
echo -e "\n\nYou may visit https://shadowsocks.org/en/config/quick-guide.html to generate Shadowsocks QR code. \n\n"
echo -e "\n\nFor iOS users, Shadowrocket is highly recommended. For other uses, an OpenWRT box with Shadowsocks and ChinaDNS is recommended. \n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment