What's the best way to automatically reconnect an interactive SSH session to re-establish the shells on terminals? I looked at autossh but that seems to be dedicated to port forwards (which I do not need).

Is there any shell-fu or utility that allows that?

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

Actually, autossh will do the same for interactive sessions as well - you may want to run the remote session in screen to keep it up across reconnects:

autossh -t you@somehost.example.com 'screen -R'

As autossh accepts the parameters that ssh does, the -t option will force a terminal (which is needed for an interactive session), and screen -R will preserve your shell across reconnects.

link|improve this answer
the -t option is not in 1.4c-1, is it? – wishi Oct 26 '11 at 14:14
/usr/share/autossh/examples/rscreen does that. with -t this is broken and connot work. – wishi Oct 26 '11 at 14:33
@wishi: I have autossh 1.4b here, and OpenSSH_5.3p1debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009. I have never yet encountered the behavior you specified - the -t switch has been in ssh for ages and ages (see ssh manpage); autossh passes the parameters it doesn't recognize to ssh (perhaps this is a regression in autossh?) Also, I don't have the .../examples/rscreen file on my system. Note that I have actually tried the command, on multiple Linux systems with different distros, and it works (therefore I vehemently oppose your assertion that it "cAnnot work"). – Piskvor Oct 26 '11 at 17:32
feedback

Perhaps: while true; do ssh user@host; done ??

Helps to run screen on the remote host to be able to pick up exactly where you left off.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.