Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script can be used to run commands on remote machines.
- # You can run commands or copy files over SCP
- # Tested on MAC OS and RHEL 7
- # Save as script.sh and write IP/Hostnames to external file example hosts.txt
- # Run /home/user/script.sh hosts.txt
- #!/bin/bash
- while read line
- do
- ssh root@"$line" "hostname; yum install net-snmp net-tools -y;" < /dev/null
- #scp /home/user/local_authorized_keys root@"$line":/root/.ssh/authorized_keys
- done < "$1"
- ##################################################
- ####### Working Example script + hosts.txt #######
- ##################################################
- # cat /home/typhoon/script.sh
- #!/bin/bash
- while read line
- do
- #ssh root@"$line" "hostname; yum install net-snmp net-tools -y;" < /dev/null
- scp /Users/typhoon/Downloads/nanorc root@"$line":/etc/nanorc
- scp -rp /Users/typhoon/Downloads/nano root@"$line":/usr/share
- done < "$1"
- # cat /home/typhoon/hosts.txt
- 192.168.0.10
- 192.168.0.11
- 192.168.0.12
- 192.168.0.13
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement