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
  • 相关阅读:
    差分隐私 differential privacy privSQL ||sql query ||sql查询系统||PrivateSQL:A Differentially Private SQL Query Engine论文笔记
    分冶法解决大整数相乘 最近对问题
    数论 矩阵交集
    STl 优先队列 C++
    备份mysql函数和存储过程
    Idea 注解模板
    excel导出
    帆软常用小技巧
    js + java文件下载
    try/finally
  • 原文地址:https://www.cnblogs.com/jinchuan16/p/9946387.html
Copyright © 2011-2022 走看看