Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muhamad-ridwant-tech/af354c7c5d2ec4cfd5aeaac5bd3f9797 to your computer and use it in GitHub Desktop.
Save muhamad-ridwant-tech/af354c7c5d2ec4cfd5aeaac5bd3f9797 to your computer and use it in GitHub Desktop.
manage multiple servers with one ssh command
## Create file "server.txt"
## then write all the server addr, and import ssh key to all server.
# example
for i in `cat server.txt`; do ssh root@${i} "Try Linux command"; done
# Check status SELinux
for i in `cat server.txt`; do ssh root@${i} "hostname && sestatus"; done
# Check IP Address
for i in `cat server.txt`; do ssh root@${i} "hostname && ip a | grep inet"; done
# Installasi Package
for i in `cat server.txt`; do ssh root@${i} "yum -y install java-1.8.0-openjdk*"; done
# SCP copy file
for i in `cat server.txt`; do scp TestFile root@${i}:TestFile; done
for i in `cat server.txt`; do scp /Folder/TestFile root@${i}:/Folder/TestFile; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment