#!/bin/sh # . /etc/init.d/functions for n in 8 7 31 41 do scp -P 52113 ~/hosts [email protected]172.16.1.${n}:~ >/dev/null 2>&1 && ssh -p 53113 -t [email protected]172.16.1.$n sudo rsync ~/hosts /etc/hosts >/dev/null 2>&1 if [ $? -eq 0 ];then action "fenfa hosts 172.16.1.$n " /bin/ture else action "fenfa hosts 172.16.1.$n " /bin/false fi done scp -P22 -r -p /tmp/oldboy [email protected]10.0.0.1:/tmp ======================================= 管理机需要的操作 yum install sshpass 如果不能安装则输入下面 cd /etc/yum.repos.d/ wget http://download.opensuse.org/repositories/home:Strahlex/CentOS_CentOS-6/home:Strahlex.repo yum install sshpass -y 分发密钥 #!/bin/bash # by syaving echo -e "\n"|ssh-keygen -t dsa -N "" &>/dev/null 2>&1 echo -e "local key is ok " #send local key in hostnode 1 2 3 4 5 for n in 1 2 3 4 5 do sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "mkdir -m 700 -p ~/.ssh/" >/dev/null 2>&1 sshpass -p 123456 scp -o StrictHostKeyChecking=no ~/.ssh/id_dsa.pub [email protected]172.16.1.$n:~/.ssh/authorized_keys >/dev/null 2>&1 sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "chmod 600 ~/.ssh/authorized_keys" >/dev/null 2>&1 done
#!/bin/bash #by syaving echo -e "\n"|ssh-keygen -t dsa -N "" &>/dev/null 2>&1 echo -e "local key is ok " #send local key in hostnode 131 132 133 134 135 for n in 131 132 133 134 135 do sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "mkdir -m 700 -p ~/.ssh/" >/dev/null 2>&1 sshpass -p 123456 scp -o StrictHostKeyChecking=no ~/.ssh/id_dsa.pub [email protected]172.16.1.$n:~/.ssh/authorized_keys >/dev/null 2>&1 sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "chmod 600 ~/.ssh/authorized_keys" >/dev/null 2>&1 done wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo yum install -y salt-master >/dev/null 2>&1 sleep 10 chkconfig salt-master on >/dev/null 2>&1 #mkdir scripts_file for n in 131 132 133 134 135 do ssh -p 22 [email protected]172.16.1.$n /bin/mkdir -p /server/scripts >/dev/null 2>&1 ssh -p 22 [email protected]172.16.1.$n /usr/bin/yum -y install salt-minion >/dev/null 2>&1 ssh -p 22 [email protected]172.16.1.$n /sbin/chkconfig salt-minion on done ============================================ # by syaving echo -e "\n"|ssh-keygen -t dsa -N "" &>/dev/null 2>&1 echo -e "local key is ok " #send local key in hostnode 131 132 133 134 135 for n in 131 132 133 134 135 do sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "mkdir -m 700 -p ~/.ssh/" >/dev/null 2>&1 sshpass -p 123456 scp -o StrictHostKeyChecking=no ~/.ssh/id_dsa.pub [email protected]172.16.1.$n:~/.ssh/authorized_keys >/de v/null 2>&1 sshpass -p 123456 ssh -o StrictHostKeyChecking=no 172.16.1.$n "chmod 600 ~/.ssh/authorized_keys" >/dev/null 2>&1 done #mkdir scripts_file for n in 131 132 133 134 135 do ssh -p 22 [email protected]172.16.1.$n /bin/mkdir -p /server/scripts >/dev/null 2>&1 ssh -p 22 [email protected]172.16.1.$n /usr/bin/yum -y install salt-minion >/dev/null 2>&1 ssh -p 22 [email protected]172.16.1.$n /bin/echo -e "master: 172.16.1.130" >> /etc/salt/minion ssh -p 22 [email protected]172.16.1.$n /etc/init.d/salt-minion start done
时间: 2024-10-29 19:05:34