Centos7安装socks5

编译安装socks5

安装编译环境

1
yum -y install gcc gcc-c++ automake make pam-devel openldap-devel cyrus-sasl-devel openssl-devel

下载源码包

项目地址: http://ss5.sourceforge.net/software.htm

1
wget https://jaist.dl.sourceforge.net/project/ss5/ss5/3.8.9-8/ss5-3.8.9-8.tar.gz

编译安装

1
2
3
tar zxvf ss5-3.8.9-8.tar.gz
cd ss5-3.8.9/
./configure && make && make install

修改配置文件ss5.conf

vim /etc/opt/ss5/ss5.conf

1
2
3
4
5
6
7
8
#auth段  SHost SPort  Authentication
#认证 源地址段 源端口 认证方式
#认证 允许所有地址所有端口访问 以用户密码验证
auth 0.0.0.0/0 - u

#permit段 Auth SHost SPort DHost DPort Fixup Group Band ExpDate
#permit段 认证方式 源地址段 源端口 目的地地址段 目的地端口 Fixup Group Band ExpDate
permit u 0.0.0.0/0 - 0.0.0.0/0 - - - - -

添加用户名和密码

vim /etc/opt/ss5/ss5.passwd

一行一个账号,用户名和密码之间用空格间隔

1
2
user1 mima123
user2 mima123

创建服务用户

1
2
3
4
# 创建服务账号ssproxy
useradd -M -s /sbin/nologin ssproxy
#-M 不指定home
#-s 指定shell为nologin

修改暴露的端口

vim /etc/sysconfig/ss5

添加一行,-b后面的参数代表监听的ip地址和端口号,-u 后面的参数表示本地计算机以哪个账户连接

1
2
3

# Add startup option here
SS5_OPTS=" -u ssproxy -b 0.0.0.0:1080"

添加权限并设置开机自启动

1
2
3
4
5
6
7
8
# 添加可执行权限
chmod +x /etc/init.d/ss5

# 加入服务
chkconfig --add ss5

# 设置开机自启动并现在启动
systemctl enable --now ss5

开机无法自启动处理

1
2
3
4
5
6
# 查看服务详情
systemctl status ss5 -l

# 错误提示
Can’t create pid file /var/run/ss5/ss5.pid
Can’t unlink pid file /var/run/ss5/ss5.pid

由于每次重启后/var/run/ss5/文件夹都会被删除,所以需要修改/etc/init.d/ss5

start段加上一句 mkdir /var/run/ss5/,

stop段的rm -f /var/run/ss5/ss5.pid改为rm -rf /var/run/ss5/

image-20220423222235864

查看本地端口监听状态

1
ss -tunlp|grep 1080