There's a server I'd like to be connected to at all times that I have an internet connection. Sometimes I turn off my laptop, sometimes my connection drops, sometimes I go from wired to wireless or vice versa. Is there any solution to get it to automatically reconnect whenever possible and resume my screen session?
4 Answers
I suspect that autossh, possibly with a little bit of scripting to automatically reconnect to the screen session, will be the way to go.
You could consider running ssh in a wrapper script.
#!/bin/sh
while ! ssh "$@"; do
echo "Reconnecting..." >/dev/stderr
done
Call the script "ssh-forever" and use it with, for example:
$ ssh-forever -t user@host screen -DR
-
1Actually, it looks like autossh already does this. It might be better to use that instead of rolling your own script. harding.motd.ca/autossh– RJHunterJun 29, 2009 at 5:04
I've never used it myself, but if I remember my hearsay correctly, Putty Tray will do that http://putty-tray.en.softonic.com/
Please comment if I'm wrong and leading John down the wrong path.
-
-
D'oh! I missed John's comment above about it being a linux box. Thanks for subtly remarking that, pgs ;)– msanfordJun 29, 2009 at 6:09
screen command is what you need, you can attach or detach to the terminal from different locations:
-
I suspect that the OP already knows about screen, given that he said "resume my screen session"...– womble ♦Jun 29, 2009 at 4:07
-
His original question already says "and resume my screen session". What he wants is a client that will do automatic reconnects when the connection is lost.– pgsJun 29, 2009 at 4:07