View previous topic :: View next topic |
Author |
Message |
slam_head Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12041246593e397dd37c54c.gif)
Joined: 06 Jan 2003 Posts: 449 Location: New York City
|
Posted: Tue Jul 26, 2005 4:20 pm Post subject: inittab master needed |
|
|
I'm try to set up an ssh tunnel using the inittab. I added the following line to the inittab:
Code: | # MYSQL Tunnel
#my:12345:respawn:/usr/bin/ssh -N -f -L 3306:127.0.0.1:3306 svradmin@securus.ny.public -p222 |
The problem is that it keeps spawning new ssh tunnels even though there is an open one. Left unchecked it opens several thousand tunnels. Any ideas why this is happening, and how to correct it? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Nuteater Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/16978633333f73140e3e859.png)
Joined: 25 Sep 2003 Posts: 193 Location: Jyväskylä, Finland
|
Posted: Tue Jul 26, 2005 4:25 pm Post subject: |
|
|
Is there a reason why you are putting it in inittab, and not in an init.d script?
Also, for a persistent ssh tunnel you might want to check out autossh (in portage). _________________ I am Nuteater, hear me roar. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
nielchiano Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 11 Nov 2003 Posts: 1287 Location: 50N 3E
|
Posted: Tue Jul 26, 2005 5:59 pm Post subject: |
|
|
inittab will start the program you request, and watch it. If it exitst, it'll restart it.
This is exactly what it is designed to do: you start SSH with the "-f" option, so ssh will fork (start another process that doest he tunnel) and exit; init will think it stopped, and restart it.
try removing the -f option, that should do.
But I agree with Nuteater: ssh-tunnel-setup isn't a job for init... its a job for init-scripts (since eth0 might not even be up) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
slam_head Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12041246593e397dd37c54c.gif)
Joined: 06 Jan 2003 Posts: 449 Location: New York City
|
Posted: Tue Jul 26, 2005 6:32 pm Post subject: |
|
|
Thank you nielchiano, it was the -f causing the problem. The reason I want it in the inittab is so that if the tunnel dies it will be restarted, which you can't get from the init scripts, but I'll take a look at autossh. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
nielchiano Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 11 Nov 2003 Posts: 1287 Location: 50N 3E
|
Posted: Tue Jul 26, 2005 10:11 pm Post subject: |
|
|
slam_head wrote: | which you can't get from the init scripts |
Why not? (BAD CODE, UNCHECKED) Code: |
while true; do
ssh -L ...
done
|
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
UberLord Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/16007251014200867ea775c.gif)
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Wed Jul 27, 2005 6:01 am Post subject: |
|
|
Because the init script would never return so the system boot would never complete ..... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
nielchiano Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 11 Nov 2003 Posts: 1287 Location: 50N 3E
|
Posted: Wed Jul 27, 2005 2:53 pm Post subject: |
|
|
UberLord wrote: | Because the init script would never return so the system boot would never complete ..... |
True,... But I'm sure there is a way around it... Anyway, that's why I put Quote: | BAD CODE, UNCHECKED |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
UberLord Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/16007251014200867ea775c.gif)
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Wed Jul 27, 2005 3:37 pm Post subject: |
|
|
This may work - I've not tested it, just typing randomly in the forum
Code: | ( while true; ssh -L ...; do ) & |
( ... ) means run ... in a sub shell
& on the end means fork a new process and return right away |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
slam_head Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12041246593e397dd37c54c.gif)
Joined: 06 Jan 2003 Posts: 449 Location: New York City
|
Posted: Wed Jul 27, 2005 9:22 pm Post subject: |
|
|
While I appreciate the discussion this generated, I've got it working in the inittab and it seems to be work fine. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
UberLord Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
![](images/avatars/16007251014200867ea775c.gif)
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Thu Jul 28, 2005 7:22 am Post subject: |
|
|
slam_head wrote: | While I appreciate the discussion this generated, I've got it working in the inittab and it seems to be work fine. |
Awwwwww. And there I was trying to show off my technical prowess
What ever floats your boat though - there is never a single correct way ![Cool 8)](images/smiles/icon_cool.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|