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
  • 相关阅读:
    iOS开发网络篇—数据缓存
    iOS开发网络篇—监测网络状态
    AFNetworking 接收text/html格式返回数据
    ios移动APP支付方案
    iOS开发网络篇—发送json数据给服务器以及多值参数
    AFNetWorking https SSL认证
    CocoaPods版本升级
    内存管理
    init 用法
    Class 用法
  • 原文地址:https://www.cnblogs.com/jinchuan16/p/9946387.html
Copyright © 2011-2022 走看看