zoukankan      html  css  js  c++  java
  • 同网段存活IP公钥分发脚本

    #!/bin/bash
    
    function bendiyum(){
    umount /dev/sr0 &> /dev/null
    [ -e /media/cdrom ] || mkdir -p /media/cdrom
    mount /dev/sr0 /media/cdrom &> /dev/null
    if [ $? -ne 0 ];then
            echo "请插入光盘"       
            exit
    fi
    cd /etc/yum.repos.d || mkdir -p /etc/yum.repos.d
    mv /etc/yum.repos.d/* /tmp
    cat > /etc/yum.repos.d/localyum.repo << FOF
    [local]
    name=local
    baseurl=file:///media/cdrom/
    gpgcheck=0
    enabled=1
    FOF
    yum -y clean all &> /dev/null
    yum makecache &> /dev/null
    [ $? -eq 0 ] && echo "成功搭建yum仓库" || echo "yum仓库搭建失败"
    }
    
    function yunyum(){
    which wget
    if [ $? -ne 0 ];then
            bendiyum
            yum -y install wget &> /dev/null
            if [ $? -ne 0 ];then
                    echo "安装wget失败"
                    exit
            fi
    else
            ping -c 2 www.baidu.com &> /dev/null
            if [ $? -ne 0 ];then
                    echo "网络不通"
                    exit
            else
                    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo &> /dev/null
                    if [ $? -eq 0 ];then
                            yum -y clean all &> /dev/null
                            yum makecache &> /dev/null
                            echo "云yum仓库搭建成功"
                    else
                            echo "云yum仓库搭建失败"
                    fi
            fi
    fi
    }
    
    which scp &> /dev/null
    if [ $? -ne 0 ];then
            yum -y install openssh-clients &> /dev/null
                    if [ $? -ne 0 ];then
                            echo "安装scp失败"
                            exit
                    fi
    fi
    which sshpass &> /dev/null
            yum -y install sshpass &> /dev/null
                    if [ $? -ne 0 ];then
                            echo "安装sshpass失败"
                            exit
                    fi
    fi
    [ -e /root/.ssh/id_rsa_pub ]
    if [ $? -ne 0 ];then
            mv /root/.ssh/* /tmp &> /dev/null
            ssh-keygen -f/root/.ssh/id_rsa -P "" &> /dev/null
    fi
    [ -e /root/.ssh/id_rsa ]
    if [ $? -ne 0 ];then
            mv /root/.ssh/* /tmp &> /dev/null
            ssh-keygen -f/root/.ssh/id_rsa -P "" &> /dev/null
    fi
    for i in 192.168.200.{1..254}
    do
            ping -c 1 -i 0.1 $i > /dev/null
            if [ $? == 0 ];then
                    sshpass -p "jinchuan" ssh-copy-id -i /root/.ssh/id_rsa.pub "-o StrictHostKeyChecking=no $i" &> /dev/null
                    if [ $? == 0 ];then
                            echo "$i 公钥分发成功"
                    fi
            fi
    done
  • 相关阅读:
    Bzoj1499: [NOI2005]瑰丽华尔兹
    Bzoj1016: [JSOI2008]最小生成树计数
    清橙A1212:剪枝
    SPOJ1825:Free tour II
    http://www.freepik.com/
    A Guide To Transclusion in AngularJS
    styling-customizing-file-inputs
    You Don't Know JS: this & Object Prototypes
    git中https和SSH的区别
    difference between match and exec
  • 原文地址:https://www.cnblogs.com/jinchuan16/p/9946387.html
Copyright © 2011-2022 走看看