Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
inittab master needed
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
slam_head
Guru
Guru


Joined: 06 Jan 2003
Posts: 449
Location: New York City

PostPosted: Tue Jul 26, 2005 4:20 pm    Post subject: inittab master needed Reply with quote

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
View user's profile Send private message
Nuteater
Apprentice
Apprentice


Joined: 25 Sep 2003
Posts: 193
Location: Jyväskylä, Finland

PostPosted: Tue Jul 26, 2005 4:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Tue Jul 26, 2005 5:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
slam_head
Guru
Guru


Joined: 06 Jan 2003
Posts: 449
Location: New York City

PostPosted: Tue Jul 26, 2005 6:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Tue Jul 26, 2005 10:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Jul 27, 2005 6:01 am    Post subject: Reply with quote

Because the init script would never return so the system boot would never complete .....
Back to top
View user's profile Send private message
nielchiano
Veteran
Veteran


Joined: 11 Nov 2003
Posts: 1287
Location: 50N 3E

PostPosted: Wed Jul 27, 2005 2:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Jul 27, 2005 3:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
slam_head
Guru
Guru


Joined: 06 Jan 2003
Posts: 449
Location: New York City

PostPosted: Wed Jul 27, 2005 9:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Jul 28, 2005 7:22 am    Post subject: Reply with quote

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 :P

What ever floats your boat though - there is never a single correct way 8)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum