16

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?

Gareth
  • 19,080
wishi
  • 405

2 Answers2

15

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.

5

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.

glenn jackman
  • 27,524