码迷,mamicode.com
首页 > 其他好文 > 详细

分发密钥

时间:2017-08-04 17:13:16      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:需要   chm   func   conf   function   安装   art   wget   class   

#!/bin/sh
#
. /etc/init.d/functions
for n in 8 7 31 41
do
   scp -P 52113 ~/hosts oldgirl@172.16.1.${n}:~ >/dev/null 2>&1 &&   ssh -p 53113 -t oldgirl@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 oldboy@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 root@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 root@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 root@172.16.1.$n /bin/mkdir -p /server/scripts >/dev/null 2>&1
ssh -p 22 root@172.16.1.$n /usr/bin/yum -y install salt-minion >/dev/null 2>&1
ssh -p 22 root@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 root@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 root@172.16.1.$n /bin/mkdir -p /server/scripts >/dev/null 2>&1
ssh -p 22 root@172.16.1.$n /usr/bin/yum -y install salt-minion >/dev/null 2>&1
ssh -p 22 root@172.16.1.$n /bin/echo -e "master: 172.16.1.130" >> /etc/salt/minion
ssh -p 22 root@172.16.1.$n /etc/init.d/salt-minion start
done

 

分发密钥

标签:需要   chm   func   conf   function   安装   art   wget   class   

原文地址:http://www.cnblogs.com/syaving/p/7286082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!