Last active
December 22, 2021 22:14
-
-
Save afresh1/005d462515ee27ab301005130fa8d470 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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