美文网首页
debian 安装 ss

debian 安装 ss

作者: zp秋枫暮霞 | 来源:发表于2017-09-11 16:42 被阅读831次

安装 debian 8

sudo sh -c 'printf "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list'  

sudo apt update  

sudo apt -t jessie-backports install shadowsocks-libev  

如果是debian 9及ubuntu 16.10或更新的系统,请使用:

sudo apt update  

sudo apt install shadowsocks-libev  

配置:
单一端口:

修改/etc/shadowsocks-libev/config.json;配置成你的设置: ip地址,端口,密码都需要你自己调整下,下面的内容仅供参考格式

{  
    "server":"111.111.111.111",  
    "server_port":8399,  
    "local_port":1080,  
    "password":"yourpassword",  
    "timeout":60,  
    "method":"aes-256-cfb"  
}  

启动:

sudo systemctl start shadowsocks-libev  
单一端口:
修改/etc/shadowsocks-libev/config.json;配置成你的设置: ip地址,端口,密码都需要你自己调整下,下面的内容仅供参考格式

**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

{  
    "server":"111.111.111.111",  
    "server_port":8399,  
    "local_port":1080,  
    "password":"yourpassword",  
    "timeout":60,  
    "method":"aes-256-cfb"  
}  

启动:

**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

sudo systemctl start shadowsocks-libev  
以上的配置过程很简单,如果你需要在这个服务器上开通多端口的设置,则需要下面的步骤:
注意: **下面的操作不仅仅适用于debian8,适用于所有systemd的系统**:
**原理**: systemd不直接执行ss-server,而是执行一个shell脚本,shell脚本再启动多个ss-server;systemd配置成forking方式
如果你想拿来主义,请按照下面的步骤操作:
1:将/etc/shadowsocks-libev/config.json复制多份,放到 /opt/shadowsocks-libev 目录下,取名如下:
ss_0_cfg.jsonss_1_cfg.jsonss_2_cfg.json
我这里复制了3份,支持同时开3个端口,当然这些文件里面的内容,**尤其是端口部分,一定要是不同的**,即你需要改成你想要设置的端口
如果你想支持10个端口,则需要准备10个端口的 .json文件,还需要修改下面步骤3中的shell script,聪明的你一定知道怎么修改的!
2:修改 /lib/systemd/system/shadowsocks-libev.service 的 [Service]节中的内容如下:

**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

[Service]  
Type=forking  
EnvironmentFile=/etc/default/shadowsocks-libev  
User=root  
LimitNOFILE=32768  
PIDFile=/var/run/shadowsocks-libev/ss_0.pid  
ExecStart=/opt/shadowsocks-libev/ss_multi_port.sh $USER $CONFFILE $DAEMON_ARGS  

其中需要注意的是 Type=forking; 而PIDFile是新加的3:关键的东西来了: /opt/shadowsocks-libev/ss_multi_port.sh; 这个文件的内容如下:

**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

#!/bin/bash  
# Program:  
#     this program used for multi-port service for shadowsocks-libev  
#     shaddowsockes-libev do not support multi port configuration, use multiple instances instead.  
#     visit https://github.com/shadowsocks/shadowsocks-libev/issues/5  for more information  
#  
#     Usage: ss_multi_port.sh user_as default_cfg daemon_opt  
#  
#     In general, this script need start as a daemon from sysV init or systemd  
#     for systemd: it is run from /etc/systemd/system/multi-user.target.wants/shadowsocks-libev.service  
#  
# History:  
# 2017-01-01    deeve.ma@gmail.com    first release  
  
  
  
# check argument number  
if [ $# != 3 ]  
then  
        echo "Usage: `basename $0` user_as default_cfg daemon_opt"  
        exit 1  
fi  
  
  
pid_file_dir=/var/run/shadowsocks-libev  
user_as=$1  
default_cfg=$2  
daemon_opt=$3  
  
  
# create pid file folder  
[ -d $pid_file_dir ] || mkdir $pid_file_dir  
  
# pid file name  
pid_0_file=$pid_file_dir/ss_0.pid  
pid_1_file=$pid_file_dir/ss_1.pid  
pid_2_file=$pid_file_dir/ss_2.pid  
pid_3_file=$pid_file_dir/ss_3.pid  
  
# config file name  
default_cfg_dir=/opt/shadowsocks-libev  
  
#cfg_0_file=$default_cfg  
cfg_0_file=$default_cfg_dir/ss_0_cfg.json  
cfg_1_file=$default_cfg_dir/ss_1_cfg.json  
cfg_2_file=$default_cfg_dir/ss_2_cfg.json  
cfg_3_file=$default_cfg_dir/ss_3_cfg.json  
  
  
  
# start service  
echo "start multi-port service:"  
/usr/bin/ss-server -a $user_as -c $cfg_0_file -f $pid_0_file $daemon_opt  
/usr/bin/ss-server -a $user_as -c $cfg_1_file -f $pid_1_file $daemon_opt  
/usr/bin/ss-server -a $user_as -c $cfg_2_file -f $pid_2_file $daemon_opt  
#/usr/bin/ss-server -a $user_as -c $cfg_3_file -f $pid_3_file $daemon_opt  
  
echo "start multi-port sevice done!"  
  
exit 0  

启动:

**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

sudo systemctl start shadowsocks-libev  

如果判断启动多端口成功了呢:
**[plain]** [view plain](http://blog.csdn.net/ytmayer/article/details/53982782#) [copy](http://blog.csdn.net/ytmayer/article/details/53982782#)

ps -ef                 # 查看输出是否有你配置的那么多个 /usr/bin/ss-server 进程  
netstat -tuap          # 查看输出的端口是否有你配置的多个端口在监听  

转载:http://blog.csdn.net/ytmayer/article/details/53982782

相关文章

网友评论

      本文标题:debian 安装 ss

      本文链接:https://www.haomeiwen.com/subject/yrnbjxtx.html