My operating system is centos6.4.
Operating system: Rhel 6.2 x86_64
Download and install the Putty software package, I downloaded the putty-0.62-1.el6.rf.x86_64.rpm
Download the address below: HTTP://RPM.PBONE.NET/INDEX.PHP3
1. Remote Host IP list file
Copy Code code as follows:
[root@localhost~]# Vim Server_list.txt
192.168.0.13
192.168.0.12
192.168.0.11
2, the remote host to perform the operation of the file
Copy Code code as follows:
[root@localhost~]# Vim Shutdown.txt
Shutdown-h now
3. Remote Shutdown Automation Script
Copy Code code as follows:
[root@localhost~]# Vim remote_shutdown.sh
For i in ' Cat server_list.txt '
Todo
Plink-l root $i-pw redhat-m/shutdown.txt <<eof
Y
Eof
Done
4, the script gives execution permission X
Copy Code code as follows:
[root@localhost~]# chmod a+x remote_shutdown.sh
5. Script running
Copy Code code as follows:
[root@localhost~]#./remote_shutdown.sh
Note: I apply the environment, all the host root user password is redhat, please adjust according to the actual environment, if irregular, can be listed as a single.
For example:
Copy Code code as follows:
Vim remote_shutdown.sh
Plink-l Root 192.168.0.12-PW password1-m/shutdown.txt
Plink-l Jane 192.168.0.35-PW password2-m/shutdown.txt
Plink-l Paul 192.168.0.77-PW Password3-m/shutdown.txt
Plink-l Root 192.168.0.19-PW password4-m/shutdown.txt
(or Plink root@192.168.0.19-pw password4-m/shutdown.txt)