Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active Dec 22, 2021
Embed
What would you like to do?
A simple clusterssh clone to ssh into many machines at once in a single tmux session. Use `set synchronize-panes` to send commands to all panes at once.
#!/bin/sh
# tssh -- Andrew Fresh <andrew AT AFresh1.com>
set -e
if [ -z "$*" ]; then
echo "usage: tssh server1 [[[server2] server3] ...]"
exit 2
fi
new=""
next="new-session -d"
for s in "$@"; do
new="$new $next ssh $s ; select-layout tiled ;"
next="split-window"
done
export TMUX_TMPDIR=`mktemp -td tssh-XXXXXXXXX`
[ -z "$TMUX_TMPDIR" ] && exit 1
trap 'rm -rf "$TMUX_TMPDIR"' 0 1 2 15
tmux $new set-option exit-unattached on \; attach-session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment