Created
June 22, 2023 03:22
-
-
Save muhamad-ridwant-tech/af354c7c5d2ec4cfd5aeaac5bd3f9797 to your computer and use it in GitHub Desktop.
manage multiple servers with one ssh command
This file contains hidden or 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
## 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