Shadowsocks服务器端的配置脚本
心血来潮租了台VPS,准备在学习iOS开发的同时学学Linux的知识,当然是从FQ开始。我把整个Shadowsocks服务器端的部署过程写成了Bash脚本。
我租的VPS是Ubuntu系统,但这个脚本应该也能在Debian下使用。CentOS服务器设置可以参考这个,大同小异。
使用之前,确保服务器上已经安装有Python2.6或2.7。该脚本应当以root用户身份运行。
脚本如下:
#!/bin/bash
# Prepare System Environment
apt-get update
apt-get upgrade
# Download python-pip and shadowsocks
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip installshadowsocks
# Creat Configuration File
mkdir /etc/shadowsocks
echo "Enter the server IP address"
read ServerIP
echo "Enter the server Port (8989 is recommended)"
read ServerPort
echo "Enter the local Port (1080 is recommended)"
read LocalPort
echo "Enter the Password"
read PSW
echo "Enter the Timeout (600 is recommended)"
read Timeout
echo "Enter the Encryption Method (aes-256-cfb is recommended)"
read EncryptionMethod
echo \{\"server\":\"$ServerIP\",\"server_port\":$ServerPort,\"local_port\":$LocalPort,\"password\":\"$PSW\",\"timeout\":$Timeout,\"method\":\"$EncryptionMethod\"\} >> /etc/shadowsocks/config.json
# Start Shadowsocks Server
ssserver -c /etc/shadowsocks/config.json -d start
# Hint & Information
echo "-----------------Hint----------------------"
echo "The Shadowsocks Server Service has launched"
echo "You can use command :"
echo " ssserver -c /etc/shadowsocks/config.json -d stop"
echo "to stop the Shadowsocks Server Service"
echo " "
echo "---------------Infomation------------------"
echo "Use the following infomation to setup your Shadowsocks Client:"
echo " "
echo " Server IP address : $ServerIP"
echo " Server Port : $ServerPort"
echo " Local Port : $LocalPort"
echo " Password : $PSW"
echo " Encryption Method : $EncryptionMethod"
echo " "
echo "You can check and modify these parameters in file : /etc/shadowsocks/config.json"
优质内容筛选与推荐>>这段代码怎么用呢?
只要在本地SSH登录远程服务器,用vim新建一个.sh脚本文件,把上面的代码复制到脚本文件里,然后执行就好了。例如,$ vim SetupShadowsocksServerService.sh # 按下i键,进入编辑状态 --> Ctrl+V粘贴代码 --> 按Esc推出编辑状态 --> 输入 :wq 保存并退出 $ bash SetupShadowsocksServerService.sh
更多有关Vim的操作可以看Vim快捷键整理