summaryrefslogtreecommitdiff
path: root/bin/ssh-and-tmux
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-06-21 10:44:50 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-06-21 10:46:21 -0700
commit134984230ac68c0bf5595ffbf4c2b1198b975803 (patch)
tree7cd2ec475952c69babfa27eaf0a85e743f0f1493 /bin/ssh-and-tmux
parent37cc1fdbc9789e129afc5f3d523240446625463b (diff)
downloaddotfiles-134984230ac68c0bf5595ffbf4c2b1198b975803.tar.gz
new ssh-and-tmux and ssh-and-tmux-term and some connecting up
Diffstat (limited to 'bin/ssh-and-tmux')
-rwxr-xr-xbin/ssh-and-tmux22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/ssh-and-tmux b/bin/ssh-and-tmux
new file mode 100755
index 00000000..0f39558a
--- /dev/null
+++ b/bin/ssh-and-tmux
@@ -0,0 +1,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 $session on $host; C-c/C-d 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' ] && exit
+done