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快捷键整理

优质内容筛选与推荐>>
1、课下作业-输入法评估
2、margin的垂直方向塌陷
3、Cygwin的安装,卸载,以及安装gdb
4、存储过程几种写法
5、Java流和文件


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号