Skip to content

Instantly share code, notes, and snippets.

@syanle
Created December 22, 2020 05:24
Show Gist options
  • Save syanle/0d134c7c58174446ac4a986fe3b9103a to your computer and use it in GitHub Desktop.
Save syanle/0d134c7c58174446ac4a986fe3b9103a to your computer and use it in GitHub Desktop.
shadowsocks+kcptun
#!/bin/bash
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -qy shadowsocks-libev
cat>/etc/systemd/system/shadowsocks-server.service<<EOF
[Unit]
Description=Shadowsocks Server
After=network.target
[Service]
ExecStart=/usr/bin/ss-server -c /etc/ss-config.json
Restart=always
[Install]
WantedBy=multi-user.target
EOF
num=$((30000 + $RANDOM))
pass=`date +%s | sha256sum | base64 | head -c 12`
cat>/etc/ss-config.json<<EOF
{
"server":["[::0]","0.0.0.0"],
"server_ipv6":"::",
"dns_ipv6":true,
"ipv6_first":true,
"server_port":$num,
"password":"$pass",
"timeout":100,
"method":"aes-256-gcm"
}
EOF
systemctl daemon-reload
systemctl enable shadowsocks-server
systemctl restart shadowsocks-server
systemctl status shadowsocks-server
VERSION=20190109
wget https://github.com/xtaci/kcptun/releases/download/v$VERSION/kcptun-linux-amd64-$VERSION.tar.gz
tar zxf kcptun-linux-amd64-$VERSION.tar.gz
rm -f client_linux_amd64 kcptun-linux-amd64-$VERSION.tar.gz
chmod a+x server_linux_amd64
mv -f server_linux_amd64 /usr/local/bin/
num=$((30000 + $RANDOM))
pass=`date +%s | sha256sum | base64 | head -c 12`
port=`grep -oP "\d{4,5}" /etc/ss-config.json`
cat>/etc/kcp-config.json<<EOF
{
"listen":":$num",
"target":"127.0.0.1:$port",
"key":"$pass",
"crypt":"aes-192",
"mode":"fast3"
}
EOF
cat>/etc/systemd/system/kcp-server.service<<EOF
[Unit]
Description=Kcptun server
After=network.target
[Service]
ExecStart=/usr/local/bin/server_linux_amd64 -c /etc/kcp-config.json
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable kcp-server
systemctl restart kcp-server
systemctl status kcp-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment