## populate hosts files. With IP or hostnames.
tee <<-'EOF' ~/.hosts >/dev/null
ip-10-42-4-10.ec2.internal
ip-10-42-4-30.ec2.internal
ip-10-42-4-31.ec2.internal
ip-10-42-4-32.ec2.internal
ip-10-42-4-33.ec2.internal
ip-10-42-4-50.ec2.internal
EOF
## if required generate SSH key
ssh-keygen -t rsa -b 4096 -o -a 100 -N "" -f ~/.ssh/id_rsa
## Distribute public key to all hosts with only 1 prompt for password:
sudo yum install sshpass
read -p "Enter SSH password:" -s SSHPASS
export SSHPASS
for host in $(<~/.hosts); do
sshpass -e ssh-copy-id ${host}
done
## Or distribute using an existing working SSH key:
#for host in $(<~/.hosts); do ssh-copy-id -f -i temp.pub ${host}; done
## check if epel is enabled
sudo yum repolist all | grep epel
## if enabled, skip to "install tools"
## if disabled, then enable:
## sudo yum-config-manager --enable epel
## if not available, install epel
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
## install tools
sudo yum install pssh tmux
## install tmux-cssh
mkdir -p ~/bin
curl -L -o ~/bin/tmux-cssh https://raw.githubusercontent.com/seanorama/tmux-cssh/master/tmux-cssh
chmod +x ~/bin/tmux-cssh
## populate host variable. Can pipe within this to choose specific hosts.
hosts=$(<~/.hosts)
## test tmux-cssh
tmux-cssh ${hosts}
## test pssh
pssh -i -H "${hosts}" uptime
Last active
July 5, 2019 14:53
-
-
Save seanorama/b3787aa52c82c61267bb8dda6b8b8e77 to your computer and use it in GitHub Desktop.
cluster-shell-tools
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment