#!/bin/bash # when mosh isn't installed on the server, but tmux is, use this to get a # fairly persistent set of remote shell sessions. I used to use autossh here, # but that means surprise dialogs asking to authorise use of an SSH key; # instead, just hit to restart a window's connection when it's # convenient # # (The reason that I get prompted is because I have a short # ServerAliveInterval and low ServerAliveCountMax, but that's desirable, # because unresponsive SSH sessions are a massive pain) host="$1" session="${2:-default}" prompt="Press any key to reconnect to tmux session $session on $host; d/C-d/C-c to give up .." while true; do ssh -t "$host" "tmux new-session -A -s $session" clear read -n 1 -r -s -p "$prompt" ch [ "$ch" = $'\04' -o "$ch" = d ] && exit done