March 2008 Archives

Keep Tunnelling - 不灭的隧道

| No Comments | No TrackBacks

我们用daemontools来控制ssh tunnel确保tunnel能在意外断开后主动连接上。在daemon中做tunnel最大的问题就是如何输入密码。这个问题可以使用以前的 ssh-attach 脚本来解决。

首先创建一个连接脚本(tunnel.sh):

#!/bin/sh
HOME=/home/jianingy
eval `$HOME/bin/ssh-attach`
ssh -p 23456 -b 0.0.0.0 -R 12345:localhost:143 xxx.xxx.xxx.xxx "vmstat 60"

再建立daemontools的run脚本:

#!/bin/sh

exec setuidgid jianingy ./tunnel.sh

用加载ssh-agent的用户(这里是jianingy)来执行tunnel.sh(即用setuidgid jianingy在指定),酱紫tunnel.sh中调用的ssh-attach便能复用已有的ssh-agent了,保证tunnel连接无须输入密码.

October 2008

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Friends' Links

Recent Comments

  • jianingy: test read more
  • mmx: thank u very much ! read more
  • FW: pls contact me with email.about APIHook. read more
  • jianingy: 这个lc是啥意思? -------- read more
  • cnhackTNT: 晕,被过滤掉了,再试试: s/(?<!\\)\$NICK/lc/e; 汗,过滤了小于符号,只好写<了呵呵 read more
  • cnhackTNT: s/(? 这样可以少打几个字呵呵 read more
  • R.Q.: 酱紫哦,了了 -------- read more

Archives

Powered by Movable Type 4.21-en