Skip to content

Instantly share code, notes, and snippets.

@serverwentdown
Created December 31, 2014 09:31
Show Gist options
  • Save serverwentdown/73b3568abd2af20ae935 to your computer and use it in GitHub Desktop.
Save serverwentdown/73b3568abd2af20ae935 to your computer and use it in GitHub Desktop.
Dirty script to connect to a cluster using nmap!
#!/bin/zsh
RUSER="ubuntu"
IFS=$'\n' HOSTS=($(nmap -oG - -sn -n 192.168.11.128-254 | grep 'Host: ' | cut -f 2 -d ' '))
WIDTH=$(tput cols)
DIV=$#HOSTS
SP=$(( $WIDTH / $DIV ))
for ip in $HOSTS; do
CMD="ssh -i somesshid_rsa $RUSER@$ip"
if [[ $HOSTS[1] == $ip ]]; then
tmux new-session -d "$CMD"
else
tmux split-window -h "$CMD"
tmux select-pane -L
tmux resize-pane -x $SP
tmux select-pane -R
fi;
done
tmux a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment