遠程給多臺主機安裝軟件
參考腳本一:
vim auto.sh
#!/bin/bash
IPS=192.168.10.
for I in {6..9};do
(
ssh root@${IPS}$I 'yum install -y vsftpd ftp lftp tree samba tftp-server bind dhcp httpd mariadb-server'
ssh root@${IPS}$I 'rpm -q vsftpd ftp lftp tree samba tftp-server bind dhcp httpd mariadb-server'
ssh root@${IPS}$I 'systemctl restart vsftpd'
ssh root@${IPS}$I 'systemctl restart smb'
ssh root@${IPS}$I 'systemctl restart rpcbind'
ssh root@${IPS}$I 'systemctl restart nfs'
ssh root@${IPS}$I 'systemctl restart mariadb'
)&
done
wait
參考腳本二:先將需要安裝的軟件寫到一個文件裏,然後用scp傳送到服務端
vim install.sh
#!/bin/bash
yum install -y vsftpd ftp lftp tree samba tftp-server bind dhcp httpd mariadb-server
rpm -q vsftpd ftp lftp tree samba tftp-server bind dhcp httpd mariadb-server
systemctl restart vsftpd
systemctl restart smb
systemctl restart rpcbind
systemctl restart nfs
systemctl restart mariadb
vim scp.sh
#!/bin/bash
IPS=192.168.10.
for I in {6..9};do
(
scp -r install.sh root@${IPS}$I:/opt/
ssh root@${IPS}$I 'bash /opt/install.sh'
)&
done
wait
遠程給多臺主機安裝軟件