unbuntu下 sock5 代理服务器 ss5 的安装和启动
主要问题是ss5官方发布的版本没有for unbuntu的, 所以下载fedora版本, 在unbuntu安装完成后, 再修改一些默认脚本,
使之适应 unbuntu
=========================
=============================
PART 2 Ubuntu 下的 ss5 安装 (和附加包 安装):
1, tar -zxvf ss5-3.8.9-1.tar.gz
./configre
发现很多包没有安装, 所以下面挨个安装
sudo apt-get install dpkg-dev
./configure
aptitude search pam | grep dev
sudo apt-get install libpam0g-dev
./configure
aptitude search ldap | grep dev
sudo apt-get install libldap2-dev
./configure
aptitude search ssl | grep dev
sudo apt-get install libssl-dev
./configure
sudo apt-get install openssl
(源程序中用到了openssl, 源代码中 /include/SS5Radius.h 有这样一行: #include <openssl/md5.h> )
---
有可能要先安装apt功能:
sudo apt-get install apt-file
sudo apt-file update
apt-file search functions
./configure
make 发现编译二进制.o 都通过了, 但在最终链接时候报错, 说MD5_xxx 几个函数没有定义.
vi src/Makefile 加入 -lcrypto 库链接
LIBS = -lpthread -rdynamic -ldl -lssl -lcrypto -lldap -lpam -lpam_misc
这时候vfork.h还是没有, 但没有关系, 可以编译和安装ss5了:
./configure
make
make install
备注: Makefile中, 相应的安装路径:
S["trc_path_base"]="/var/log/ss5"
539 S["log_path_base"]="/var/log/ss5"
540 S["man_path_base"]="/usr/share/man"
541 S["doc_path_base"]="/usr/share/doc"
542 S["bin_path_base"]="/usr/sbin"
543 S["conf_path_base"]="/etc/opt"
544 S["lib_path_base"]="/usr/lib"
然后要对ss5的启动脚本进行修正:
因为安装包是for fedora的, 直接安装在unbuntu中, 有两个问题, 要修改:
1. 安装的默认启动脚本, 目录不对
2. 启动脚本中, 用到了两个fedora平台的启动子脚本, unbuntu里没有, 所以要禁用.
3. 对启动脚本做一些其它的小修正
首先将安装到fedora系统默认目录下的启动脚本, copy 到 unbuntu 默认启动目录里面,
然后改动成下面脚本[参见:启动脚本ss5内容],
或者直接copy 或者 upload 我修改过的脚本到/etc/init.d/ss5:
对ss5进行配置:
修改/etc/opt/ss5 目录下的两个文件: ss5.conf and ss5.passwd
修改配置文件:
/etc/opt/ss5/ss5.conf
修改:
auth 0.0.0.0/0 – -
改成:
auth 0.0.0.0/0 – u
修改:
permit – 0.0.0.0/0 – 0.0.0.0/0 – – – – -
改成:
permit u 0.0.0.0/0 – 0.0.0.0/0 – – – – -
修改配置文件 (这一步也可以省略, 我改的启动脚本中已经带这个参数):
/etc/sysconfig/ss5
打开:SS5_OPTS=” -u root”
然后在/etc/opt/ss5/ss5.passwd中, 一行一个用户+密码
# cat ss5.passwd
test 123456
最后启动ss5, 可能第一次运行时候, 需要手动建立pid目录:
可能需要修改脚本权限:
ls -la /etc/init.d/
chmod 700 /etc/init.d/ss5
然后启动, 停止下测试:
# /etc/init.d/ss5 start
# /etc/init.d/ss5 stop
# /etc/rc.d/init.d/ss5 start
# /etc/rc.d/init.d/ss5 start
doneting ss5… [ OK ]
再重启下看看:
# /etc/rc.d/init.d/ss5 restart
Restarting ss5… Shutting down ss5…
done [ OK ]
doneting ss5… [ OK ]
没问题了, 你就可以使用服务器的IP, 端口1080, 用户test, 密码123456
来测试你的socks5服务器了, 更多高级应用, 参看ss5.conf, 里面有详细的说明.
-----------
启动脚本ss5内容:
首先将安装到fedora系统默认目录下的启动脚本, copy 到 unbuntu 默认启动目录里面,
然后改动成下面脚本, 后者直接copy 下面脚本内容到/etc/init.d/ss5:
cp /etc/rc.d/init.d/ss5 /etcinit.d/ss5
#!/bin/sh
#
# chkconfig: 345 20 80
# description: This script takes care of starting \
# and stopping ss5
#
OS=`uname -s`
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
#SS5_LOG_FILE = "/var/log/ss5log"
# Source function library.
# . /etc/rc.d/init.d/functions
# ./lib/lsb/init-functions
# Source networking configuration.
# . /etc/sysconfig/network
# Check that networking is up.
# [ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/sbin/ss5 ] || exit 0
fi
# Test custom variables
test -f /etc/sysconfig/ss5 && . /etc/sysconfig/ss5
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Starting ss5... "
if [ $OS = "Linux" ]; then
# daemon /usr/sbin/ss5 -t $SS5_OPTS $SS5_OPTS = -u root in file: /etc/sysconfig/ss5
# /usr/sbin/ss5 -t -m -b 0.0.0.0:1080 -u root
/usr/sbin/ss5 -t -b 0.0.0.0:1080 -u root
# touch /var/lock/subsys/ss5
touch /var/run/ss5/ss5.pid
# else
# if [ $OS = "SunOS" ]; then
# /usr/sbin/ss5 -t
# touch /var/lock/subsys/ss5
else
/usr/local/sbin/ss5 -t
touch /var/run/ss5/ss5.pid
# touch /var/lock/subsys/ss5
# fi
fi
echo "done"
;;
stop)
# Stop daemon.
echo "Shutting down ss5... "
killall ss5
rm -f /var/run/ss5/ss5.pid
echo "done"
;;
reload)
# Reload configuration
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
echo -n "Reloading ss5... "
killproc ss5 -1
else
pkill -HUP ss5
fi
echo "done reload"
;;
restart)
# Restart daemon
echo -n "Restarting ss5... "
$0 stop
$0 start
;;
status)
if [ $OS = "Linux" ] || [ $OS = "SunOS" ]; then
status ss5
fi
;;
*)
echo "Usage: ss5 {start|stop|status|restart|reload}"
exit 1
;;
esac
exit 0
=========================
PART 1 ss5的日常启动维护:
15:54:51-~$ sudo /etc/init.d/ss5 stop
Shutting down ss5...
Terminated
15:55:04-~$ sudo /etc/init.d/ss5 start
Starting ss5... done
15:55:10-~$ ps -aux | grep ss5
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root 26646 0.0 0.0 6580 1332 ? S 15:55 0:00 /usr/sbin/ss5 -t -m -b 0.0.0.0:1080 -u root
15:55:14-~$
---------
将ss5 加入cron周期进程; 每周杀死一次, 再重新启动.
sudo vi /etc/cron.weekly/sp
1 #!/bin/sh
2 #
3 # cron weekly
4
5 /etc/init.d/ss5 stop
6
7 sleep 10s
8
9 /etc/init.d/ss5 start
10
11 exit 0
22:11:27-~$ ps aux| grep ss5
root 22708 0.0 0.0 6576 1328 ? S 22:11 0:00 /usr/sbin/ss5 -t -m -b 0.0.0.0:1080 -u root
suyu 22711 0.0 0.0 2996 732 pts/3 R+ 22:11 0:00 grep ss5
22:11:36-~$ sudo /etc/cron.weekly/sp
Shutting down ss5...
/etc/cron.weekly/sp: line 5: 22716 Terminated /etc/init.d/ss5 stop
Starting ss5... done
22:13:40-~$ ps aux| grep ss5
root 22724 0.0 0.0 6576 1328 ? S 22:13 0:00 /usr/sbin/ss5 -t -m -b 0.0.0.0:1080 -u root
下周日中午, 看看经常是否正常被重启
===============
PART 3 附录
常用的APT命令参数
2006-10-26 23:54:33
apt-cache search package 搜索包
apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package 安装包
sudo apt-get install package - - reinstall 重新安装包
sudo apt-get -f install 修复安装"-f = --fix-missing"
sudo apt-get remove package 删除包
sudo apt-get remove package - - purge 删除包,包括删除配置文件等
sudo apt-get update 更新源
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-get dselect-upgrade 使用 dselect 升级
apt-cache depends package 了解使用依赖
apt-cache rdepends package 是查看该包被哪些包依赖
sudo apt-get build-dep package 安装相关的编译环境
apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
----------
aptitude search manual
Each search result is listed on a separate line.
The first character of each line indicates the current state of the package:
the most commonstates are p, meaning that no trace of the package exists on the system,
c, meaning that the package was deleted but its configuration files remain on the system,
i, meaning that the package is installed, and
v, meaning that the package is virtual.
The second character indicates the stored action (if any; otherwise a blank space is displayed)
to be performed on the package,
with the most common actions bein