Skip to content

Instantly share code, notes, and snippets.

Last active December 11, 2023 09:01
Show Gist options
  • Save tianjianchn/888a610036c743c4aba2ea1e82f4a216 to your computer and use it in GitHub Desktop.
Save tianjianchn/888a610036c743c4aba2ea1e82f4a216 to your computer and use it in GitHub Desktop.
# Install Shadowsocks on CentOS 7
echo "Installing Shadowsocks..."
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
SS_IP=`ip route get 1 | awk '{print $NF;exit}'`
SS_PASSWORD=$(random-string 32)
SS_METHOD=camellia-256-cfb #or camellia-256-cfb
# Install deps
echo "\nInstalling Dependencies"
yum install epel-release -y
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel libev-devel -y
## Install shadowsocks-libev
echo "\nInstalling shadowsocks-libev"
wget -N --no-check-certificate
cp librehat-shadowsocks-epel-7.repo /etc/yum.repos.d/
yum update
yum install shadowsocks-libev
# Create shadowsocks config file
echo "\nCreating shadowsocks config file"
cat <<EOF > /etc/shadowsocks.json
"server": "",
"server_port": ${SS_PORT},
"password": "${SS_PASSWORD}",
"method": "${SS_METHOD}",
"local_address": "",
"fast_open": false,
"workers": 1
## Add system service on CentOS7
echo "\nCreating system service"
cat <<EOF > /etc/systemd/system/shadowsocks.service
Description=Shadowsocks Server Service auditd.service
ExecStart=/usr/bin/ss-server -c /etc/shadowsocks.json
systemctl enable shadowsocks
## Start service
echo "\nStarting shadowsock system service"
systemctl stop shadowsocks
systemctl start shadowsocks
# View service status
echo "\nChecking shadowsock system service status"
sleep 5
systemctl status shadowsocks -l
## Add service on CentOS7 firewall
echo "\nCreating shadowsock firewalld service"
cat <<EOF > /etc/firewalld/services/shadowsocks.xml
<?xml version="1.0" encoding="utf-8"?>
<description>Enable Shadowsocks on ${SS_PORT}/tcp.</description>
<port protocol="tcp" port="${SS_PORT}"/>
firewall-cmd --permanent --zone=public --add-service=shadowsocks
# or if you don't want to use service, try:
# firewall-cmd --zone=public --add-port=${SS_PORT}/tcp --permanent
## Reload firewall to apply
firewall-cmd --reload
echo "\n================================"
echo ""
echo "Congratulations! Shadowsocks has been installed on your system."
echo "Your shadowsocks connection info:"
echo "--------------------------------"
echo "server: ${SS_IP}"
echo "server_port: ${SS_PORT}"
echo "password: ${SS_PASSWORD}"
echo "method: ${SS_METHOD}"
echo "--------------------------------"
Copy link


  1. Click the raw button on the right corner of to get the raw content url, like
  2. On your CentOS7 server, run bash <(curl -s the-url), like bash <(curl -s

Copy link

holyen commented Apr 5, 2017

装了 还是无法启动
service shadowsocks-libev start
shadowsocks-libev: 未被识别的服务

Copy link

holyen commented Apr 5, 2017


Copy link

what about shadowsocks with v2ray and so on?

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