Have a look at http://www.sshkeychain.org
Main Topics
Browse All TopicsI have a reverse shell that I need to keep connected.
$ ssh -NR 3333:localhost:22 myhost.remote.com
So that I can open a shell on myhost with $ ssh -p 3333 localhost.
The problem is that the connection sometimes 'times out' after a few hours, or less, and i need to monitor it and restart it when it fails. I do not have 'auto-login' set up, but i can do that myself, or it'd be nice to share points with someone who links to a tutorial to automatically use ssh/scp, etc without a password.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Have a look at http://www.sshkeychain.org
There are two ways to avoid SSh timeout.. one is to set it on the server and the other on the client,
ClientAliveInterval 60 (On the server)
This would send a message to the client every 60 seconds to request a response thereby keeping the connection open.
ServerAliveInterval 60 (On the SSH client)
This would send a message to the server every 60 seconds to request a response thereby keeping the connection open.
check the man page for sshd_config for mroe details.
Business Accounts
Answer for Membership
by: mrcustardPosted on 2009-10-22 at 16:24:20ID: 25640062
Is it sshd that dies or just that reverse tunnel? Also do you have a timeout set? Do you notice that the tunnel drops every hour, 2 hours, or just randomly?
If it's a network issue that causes the problem for a quick work around you could use a cron job that runs at a pre-determined interval (1 minute, 5 minutes) that runs a script that will check SSH and restart it.
Thanks,
M.