Linux(debian) 配置 shadowsocks服务器

2019年5月3日 0 条评论 122 次阅读 0 人点赞

1.安装Python pip组件

apt-get install python-pip

2.用pip安装shadowsocks

pip install shadowsocks

更新shadowsocks代码

pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U

启动代码

ssserver -p 8388 -k password-m aes-256-cfb -d start

配置文件

{
"server":"0.0.0.0",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"pawssword",
"timeout":300,
"method":"aes-256-cfb"
}

配置文件启动方式

ssserver -c /etc/shadowsocks.json -d start

添加开机启动

vi /etc/init.d/shadowsocks
#!/bin/sh
# chkconfig: 2345 90 10
# description: Start or stop the Shadowsocks server
#
### BEGIN INIT INFO
# Provides: Shadowsocks
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start or stop the Shadowsocks server
### END INIT INFO
# Author: xju <[email protected]>
name=shadowsocks
BIN=/usr/bin/ssserver
conf=/etc/shadowsocks.json
start(){
    $BIN -c $conf -d start
    RETVAL=$?
    if [ "$RETVAL" = "0" ]; then
        echo "$name start success"
    else
        echo "$name start failed"
    fi
}
stop(){
    pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${BIN}" | awk '{print $2}'`
    if [ ! -z $pid ]; then
        $BIN -c $conf -d stop
        RETVAL=$?
        if [ "$RETVAL" = "0" ]; then
            echo "$name stop success"
        else
            echo "$name stop failed"
        fi
    else
        echo "$name is not running"
        RETVAL=1
    fi
}
status(){
    pid=`ps -ef | grep -v grep | grep -v ps | grep -i "${BIN}" | awk '{print $2}'`
    if [ -z $pid ]; then
        echo "$name is not running"
        RETVAL=1
    else
        echo "$name is running with PID $pid"
        RETVAL=0
    fi
}
case "$1" in
'start')
    start
    ;;
'stop')
    stop
    ;;
'status')
    status
    ;;
'restart')
    stop
    start
    RETVAL=$?
    ;;
*)
    echo "Usage: $0 { start | stop | restart | status }"
    RETVAL=1
    ;;
esac
exit $RETVAL

chmod a+x /etc/init.d/shadowsocks

update-rc.d shadowsocks defaults

月下

我想要的,从始至终,不过一个你罢了。

文章评论(0)

你必须 登录 才能发表评论