zoukankan      html  css  js  c++  java
  • ssh自动分发密匙脚本样板

    #!/bin/bash
    rom=/media/cdrom
    dir=/etc/yum.repos.d
    Use=$1
    mima=$2
    function yumj(){
    [ -d "$rom" ] || mkdir -p "$rom"
    /bin/umount /dev/sr0
    /bin/mount /devsro0 $rom
    [ -d "$dir" ] || mkdir -p "$dir"
    cd "$dir" &&
    mv * /tmp/
    /bin/cat > /etc/yum.repos.d/local.repo << fof
    [local]
    name=localrepo
    basenurl=:///"$rom"
    gpgcheck=0
    enabled=1
    fof
    /usr/bin/yum -y clean all &>/dev/null
    /usr/bin/yum makecache &>/dev/null
    [ $? -eq 0 ] || echo "本地yum出错"
    which "wget"
    rom=/media/cdrom
    dir=/etc/yum.repos.d
    Use=$1
    mima=$2
    function yumj(){
    [ -d "$rom" ] || mkdir -p "$rom"
    /bin/umount /dev/sr0
    /bin/mount /devsro0 $rom
    [ -d "$dir" ] || mkdir -p "$dir"
    cd "$dir" &&
    mv * /tmp/
    /bin/cat > /etc/yum.repos.d/local.repo << fof
    [local]
    name=localrepo
    basenurl=:///"$rom"
    gpgcheck=0
    enabled=1
    fof
    /usr/bin/yum -y clean all &>/dev/null
    /usr/bin/yum makecache &>/dev/null
    [ -d "$rom" ] || mkdir -p "$rom"
    /bin/umount /dev/sr0
    /bin/mount /devsro0 $rom
    [ -d "$dir" ] || mkdir -p "$dir"
    cd "$dir" &&
    mv * /tmp/
    /bin/cat > /etc/yum.repos.d/local.repo << fof
    [local]
    name=localrepo
    basenurl=:///"$rom"
    gpgcheck=0
    enabled=1
    fof
    /usr/bin/yum -y clean all &>/dev/null
    /usr/bin/yum makecache &>/dev/null
    [ $? -eq 0 ] || echo "本地yum出错"
    which "wget"
    #!/bin/bash
    rom=/media/cdrom
    dir=/etc/yum.repos.d
    Use=$1
    mima=$2
    function yumj(){
    [ -d "$rom" ] || mkdir -p "$rom"
    /bin/umount /dev/sr0
    /bin/mount /devsro0 $rom
    [ -d "$dir" ] || mkdir -p "$dir"
    cd "$dir" &&
    mv * /tmp/
    /bin/cat > /etc/yum.repos.d/local.repo << fof
    [local]
    name=localrepo
    basenurl=:///"$rom"
    gpgcheck=0
    enabled=1
    fof
    /usr/bin/yum -y clean all &>/dev/null
    /usr/bin/yum makecache &>/dev/null
    [ $? -eq 0 ] || echo "本地yum出错"
    which "wget"
    [ $? -eq 0 ] || /usr/bin/yum -y install wget &>/dev/null
    [ $? -eq 0 ] || (/bin/echo "wget error" && exit)
    /usr/bin/wget http://mirrors.aliyun.com/repo/epel-6.repo
    [ $? -eq 0 ] || (/bin/echo "yun源出错" && exit)
    /usr/bin/yum -y clean all &>/dev/null
    /usr/bin/yum makecache &>/dev/null
    [ $? -eq 0 ] || (/bin/echo "yun缓存错误" && exit)
    /bin/echo "yum ok"
    }
    
    /bin/ping  -c 2 www.baidu.com &>/dev/null
    [ $? -eq 0 ] || (/bin/echo "没网" && exit)
    which  "sshpass" &>/dev/null
    [ $? -eq 0 ] || /usr/bin/yum -y install sshpass &>/dev/null
    if [ $? -ne 0 ] ;then
     yumj
     /usr/bin/yum -y install sshpass &>/dev/null || (echo "sshpass error" && exit)
    fi
    [ -d ~/.ssh ] || mkdir -p ~/.ssh ; chmod 700 ~./ssh
    rm -rf ~/.ssh/id_*
    ssh-keygen -t dsa -f ~/.ssh/id_dsa -P "" &>/dev/null
    for i in 192.168.200.{1..245}
    do
    /bin/ping  -c 1 -i 0.1 $i &>/dev/null
    if
            [ $? -eq 0 ];then
            sshpass -p $mima ssh-copy-id -i ~/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no $Use@$i"
            echo "$i 密匙成功"
    fi
    done
  • 相关阅读:
    (转)Javascript面向对象编程(二):构造函数的继承(作者:阮一峰)
    (转)Javascript 面向对象编程(一):封装(作者:阮一峰)
    asp.net的3个经典范例(ASP.NET Starter Kit ,Duwamish,NET Pet Shop)学习资料
    (转)Ajax的原理和应用
    在ASP.NET MVC应用程序中实现Server.Transfer()类似的功能
    D2GS1.11 的DC Key的相關設置指南
    Win64位操作系统无法运行暗黑2战网D2GS的解决办法
    PVPGN 暗黑破坏神2 1.11b战网配置问题汇总
    PVPGN1.8.2 + D2GS1.11(38)搭建暗黑破坏神1.11b战网(配置指南)
    FineUI Grid控件右键菜单的实现
  • 原文地址:https://www.cnblogs.com/cash-su/p/9888586.html
Copyright © 2011-2022 走看看