This website requires JavaScript.

shadowsocks 一个好东西

2018.04.08 11:43字数 3140阅读 484喜欢 0评论 0
  1. yum install nodejs
  2. npm install -g shadowsocks

  3. 如果报错,可能是openssl的版本问题

  4. yum update openssl 试试

  5. mkdir -p /etc/shadowsocks

  6. vi /etc/shadowsocks/config.json
{
    "server": "0.0.0.0",
    "server_port": 83,
    "local_port": 1080,
    "password": "password@try",
    "timeout": 60,
    "method": "aes-256-cfb"
}

vi /etc/shadowsocks/config.json

{
    "server": "0.0.0.0",
    "server_port": 83,
    "local_port": 1081,
    "password": "password@try",
    "port_password": {
        "8380": "password@try",
        "8381": "password@try",
        "8382": "password@try",
        "8383": "password@try",
    },
    "timeout": 60,
    "method": "aes-256-cfb"
}

/usr/bin/ssserver -c /etc/shadowsocks/user.json

创建开机脚本
vi /etc/init.d/shadowsocks #填写下方脚本

#!/bin/bash
#
# Script to run Shadowsocks in daemon mode at boot time.
# ScriptAuthor: icyboy
# Revision 1.0 - 14th Sep 2013
#====================================================================
# Run level information:
# chkconfig: 2345 99 99
# Description: lightweight secured scoks5 proxy
# processname: ss-server
# Author: Max Lv <max.c.lv@gmail.com>;
# Run "/sbin/chkconfig --add shadowsocks" to add the Run levels.
#====================================================================

#====================================================================
# Paths and variables and system checks.

# Source function library
./etc/rc.d/init.d/functions

# Check that networking is up.
#
[ ${NETWORKING} ="yes" ] || exit 0

# Daemon
NAME=shadowsocks-server
DAEMON=/usr/bin/ssserver

# Path to the configuration file.
#
CONF=/etc/shadowsocks/user.json

#USER="nobody"
#GROUP="nobody"

# Take care of pidfile permissions
mkdir /var/run/$NAME 2>/dev/null || true
#chown "$USER:$GROUP" /var/run/$NAME

# Check the configuration file exists.
#
if [ ! -f $CONF ] ; then
echo "The configuration file cannot be found!"
exit 0
fi

# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/shadowsocks

# Path to the pid file.
#
PID=/var/run/$NAME/pid


#====================================================================

#====================================================================
# Run controls:

RETVAL=0

# Start shadowsocks as daemon.
#
start() {
if [ -f $LOCK_FILE ]; then
echo "$NAME is already running!"
exit 0
else
echo -n $"Starting ${NAME}: "
#daemon --check $DAEMON --user $USER "$DAEMON -f $PID -c $CONF > /dev/null"
daemon $DAEMON -c $CONF -f $PID
fi

RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}


# Stop shadowsocks.
#
stop() {
echo -n $"Shutting down ${NAME}: "
killproc -p ${PID}
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
rm -f ${PID}
echo
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $DAEMON
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac

exit $RETVAL

如果创建开机脚本失败,可以尝试直接加启动项

vi /etc/rc.d/rc.local
/usr/bin/ssserver -c /etc/shadowsocks/user.json