实现需要的包: ucspi-tcp-0.88.tar.gz(tcpserver管理)
daemotools(supervise,tai64nlocal,multilog==有用的工具都要安装它)
tcpserver的run脚本
multilog 的run脚本
==========================================================
daemontools-0.76.tar.gz
ucspi-tcp-0.88.tar.gz
netqmail-1.05.tar.tar(里面有所上两个包的补丁)
===========================================================
开始安装tcpserver
[root@localhost local]# tar -zxvf ucspi-tcp-0.88.tar.gz
[root@localhost local]# tar -zxvf netqmail-1.05.tar.tar
[root@localhost local]# cd ucspi-tcp-0.88
[root@localhost ucspi-tcp-0.88]# patch < /usr/local/netqmail-1.05/other-patches/ucspi-tcp-0.88.errno.patch
patching file error.h
[root@localhost ucspi-tcp-0.88]# make
[root@localhost ucspi-tcp-0.88]# make setup check
./install
./instcheck
[root@localhost ucspi-tcp-0.88]#
==================================================================
实验tcpserver启动:
[root@localhost /]# mkdir service
[root@localhost /]# cd service/
[root@localhost service]# mkdir sshd
[root@localhost service]# chmod 755 sshd/
[root@localhost service]# cd sshd
[root@localhost sshd]# vi run
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH
sleep 5
tcprules allow.cdb allow.tmp < allow
exec env - PATH=$PATH \
tcpserver -HRDl0 -x allow.cdb -u 0 0 ssh sshd -i -e 2>&1
[root@localhost sshd]# vi allow
:allow
[root@localhost sshd]# chmod 755 run
[root@localhost sshd]# tcpserver: fatal: unable to bind: address already used
[1]+ Exit 111 ./run
---出现如上错误
停掉ssh
[root@localhost sshd]# service sshd stop
[root@localhost sshd]# ./run &
[1] 3281
[root@localhost sshd]# ps ux|grep 'tcp'
root 3281 0.7 0.3 1616 500 pts/0 S 19:04 0:00 tcpserver -HRDl0 -x allow.cdb -u 0 0 ssh sshd -i -e
root 3304 0.0 0.3 1680 496 pts/0 R+ 19:04 0:00 grep tcp
[root@localhost sshd]# vi allow
10.4.5.209:deny
实验结果关掉session后连接不上
==============================================
以上是tcpserver实现ssh配置
=============================================
===================================================
用daemontools实现自动将tcpserver启动
===================================================
安装:daemontools-0.76.tar.gz
[root@localhost local]# tar -zxvf daemontools-0.76.tar.gz
[root@localhost local]# cd admin/daemontools-0.76/src/
[root@localhost src]# patch < /usr/local/netqmail-1.05/other-patches/daemontools-0.76.errno.patch
patching file error.h
[root@localhost daemontools-0.76]# package/install
[root@localhost sshd]# mkdir log
[root@localhost sshd]# pwd
/service/sshd
[root@localhost sshd]# ls
allow allow.cdb log run supervise
[root@localhost log]# cat run
#!/bin/sh
exec setuidgid root multilog t s1000000 n100 ./main
====================================================================
如果不出现此进程(readproctitle service errors:),可以把1857 2009这两个进程kill掉,自动重起下。
[root@localhost service]# ps ux|grep 'src'
root 2342 0.0 0.3 1684 500 pts/1 R+ 21:37 0:00 grep src
[root@localhost service]# ps ux|grep 'srs'
[root@localhost service]# ps ux|grep 'svs'
root 1857 0.0 0.8 2308 1060 ? Ss 21:32 0:00 /bin/sh /command/svscanboot
root 2009 0.0 0.2 1584 360 ? S 21:32 0:00 svscan /service
root 2355 0.0 0.3 1680 496 pts/1 R+ 21:38 0:00 grep svs
[root@localhost service]# ps ux|grep 're'
root 6 0.0 0.0 0 0 ? S< 21:31 0:00 [kthread]
root 1823 0.1 2.1 4236 2664 ? Ss 21:32 0:00 hald --retain-privileges
root 2010 0.0 0.2 1412 260 ? S 21:32 0:00 readproctitle service errors: ................................................................................................................................................................................................................................................................................................................................................................................................................
root 2358 0.0 0.4 1688 528 pts/1 R+ 21:38 0:00 grep re
[root@localhost service]#
[root@localhost main]# pwd
/service/sshd/log/main
[root@localhost main]# tail -f current
@4000000046162bdb0f8cd3cc Accepted password for root from 172.18.3.194 port 3502 ssh2
@4000000046162bdb0f8daaa4 Accepted password for root from 172.18.3.194 port 3502 ssh2
nohup svscanboot & 启动tcpserver
svc -d /service/sshd.................停止 ssh
svc -t /service/sshd.................重起 ssh
svc -u /service/sshd.................启动 ssh
svstat /service/sshd.................查看状态
如果以下进程不存在
[root@localhost]# ps aux|grep svs
root 18821 0.0 0.0 4492 1056 pts/0 S 21:13 0:00 /bin/sh /usr/bin/svscanboot
root 18823 0.0 0.0 1704 348 pts/0 S 21:13 0:00 svscan /service
root 18932 0.0 0.0 3924 688 pts/0 S+ 21:13 0:00 grep svs
可以运行:nohup /usr/bin/svscanboot &
The daemontools package contains svscanboot, svscan, supervise, svc, svok, svstat, fghack, pgrphack, readproctitle, multilog, tai64n, tai64nlocal, setuidgid, envuidgid, envdir, softlimit and setlock
阅读(1291) | 评论(0) | 转发(0) |