实现批量远程主机ssh配置
创建远程主机IP文件
[root@localhost script]# cat ip.txt
192.168.121.10
192.168.121.11
192.168.121.12
192.168.121.13
192.168.121.14
脚本实例
#!/bin/bash
#modify ssh config
#v1.0 itwnagqiang 2020-12-28
for ip in `cat ip.txt`
do
{
ping -c1 $ip &> /dev/null
if [ $? -eq 0 ];then
ssh $ip "sed -ri '/^#UseNDS/cUseDNS no/' /etc/sshd/sshd_config"
ssh $ip "sed -ri '/^GSSAPIAuthentication/cGSSAPIAuthentication no/' /etc/sshd/sshd_config"
ssh $ip "systemctl disable --now firewalld"
ssh $ip "sed -ri '/^SELINUX/cSELINUX=disabled/' /etc/selinux/config"
ssh $ip "setenforce 0"
fi
}&
done
wait
echo "modify is successful!"