blob: d11c3d73f4f31988a653048ca52d551b3c35d329 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/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 <Ret> 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 [1m$session[0m on [1m$host[0m; 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
|