Skip to content

Instantly share code, notes, and snippets.

@greggroth
Created May 21, 2014 14:03
Show Gist options
  • Save greggroth/658fb907ff8311705099 to your computer and use it in GitHub Desktop.
Save greggroth/658fb907ff8311705099 to your computer and use it in GitHub Desktop.
Control multiple ssh connections using Tmux. It creates a new tmux window with a pane ssh'd to each listed host and syncronizes the panes so input is sent to each pane. Inspired by csshx (https://code.google.com/p/csshx/).
#!/bin/bash
tmux_ssh () {
tmux send-keys 'ssh ' $1 'C-m'
}
split_and_ssh () {
tmux split-window -h
tmux_ssh $host
}
tmux new-window
tmux_ssh $1
for host in ${@:2}; do
split_and_ssh $host
done
tmux select-layout tiled
tmux setw synchronize-panes on
@greggroth
Copy link
Author

Usage:

$ cssht host1 host2 host3 etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment