2

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?

2
  • Are you running windows or linux on your laptop?
    – pgs
    Jun 29, 2009 at 4:22
  • Linux Please enter at least 15 characters
    – user10986
    Jun 29, 2009 at 4:45

4 Answers 4

3

I suspect that autossh, possibly with a little bit of scripting to automatically reconnect to the screen session, will be the way to go.

4
  • Telling ssh to execute 'screen -DR' at the remote host is likely to be sufficient.
    – pgs
    Jun 29, 2009 at 4:30
  • You'll probably want to throw a -t at SSH, in that case, but yeah I think that'll work.
    – womble
    Jun 29, 2009 at 4:49
  • screen, definitely. Jun 29, 2009 at 6:30
  • @Steve Lacey: Huh?
    – womble
    Jun 29, 2009 at 9:04
2

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
1
  • 1
    Actually, it looks like autossh already does this. It might be better to use that instead of rolling your own script. harding.motd.ca/autossh
    – RJHunter
    Jun 29, 2009 at 5:04
1

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.

2
  • Looks like a good solution for windows clients.
    – pgs
    Jun 29, 2009 at 5:13
  • D'oh! I missed John's comment above about it being a linux box. Thanks for subtly remarking that, pgs ;)
    – msanford
    Jun 29, 2009 at 6:09
-1

screen command is what you need, you can attach or detach to the terminal from different locations:

http://www.howtoforge.com/linux_screen

2
  • 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.
    – pgs
    Jun 29, 2009 at 4:07

You must log in to answer this question.