博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssh自动分发密匙脚本样板
阅读量:4638 次
发布时间:2019-06-09

本文共 2584 字,大约阅读时间需要 8 分钟。

 
#!/bin/bashrom=/media/cdromdir=/etc/yum.repos.dUse=$1mima=$2function 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=localrepobasenurl=:///"$rom"gpgcheck=0enabled=1fof/usr/bin/yum -y clean all &>/dev/null/usr/bin/yum makecache &>/dev/null[ $? -eq 0 ] || echo "本地yum出错"which "wget"rom=/media/cdromdir=/etc/yum.repos.dUse=$1mima=$2function 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=localrepobasenurl=:///"$rom"gpgcheck=0enabled=1fof/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=localrepobasenurl=:///"$rom"gpgcheck=0enabled=1fof/usr/bin/yum -y clean all &>/dev/null/usr/bin/yum makecache &>/dev/null[ $? -eq 0 ] || echo "本地yum出错"which "wget"#!/bin/bashrom=/media/cdromdir=/etc/yum.repos.dUse=$1mima=$2function 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=localrepobasenurl=:///"$rom"gpgcheck=0enabled=1fof/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/nullif [ $? -ne 0 ] ;then yumj /usr/bin/yum -y install sshpass &>/dev/null || (echo "sshpass error" && exit)fi[ -d ~/.ssh ] || mkdir -p ~/.ssh ; chmod 700 ~./sshrm -rf ~/.ssh/id_*ssh-keygen -t dsa -f ~/.ssh/id_dsa -P "" &>/dev/nullfor i in 192.168.200.{1..245}do/bin/ping  -c 1 -i 0.1 $i &>/dev/nullif        [ $? -eq 0 ];then        sshpass -p $mima ssh-copy-id -i ~/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no $Use@$i"        echo "$i 密匙成功"fidone

转载于:https://www.cnblogs.com/wangyinuo/p/9929675.html

你可能感兴趣的文章
代理 模式
查看>>
[git] 细说commit (git add/commit/diff/rm/reset 以及 index 的概念)
查看>>
DOM Core和HTML DOM的区别
查看>>
SurfaceView+MediaPlay的bug们
查看>>
网络表示学习总结
查看>>
完成评论功能
查看>>
far和near
查看>>
Python爬虫实战四之抓取淘宝MM照片
查看>>
2015 Multi-University Training Contest 1
查看>>
C#判断一个字符串是否是数字或者含有某个数字
查看>>
SVN使用指南
查看>>
【转载】掌 握 3 C ‧ 迎 接 亮 丽 职 涯
查看>>
爬取网站附件
查看>>
java基础图形界面和IO系统
查看>>
javascript学习笔记
查看>>
hdu 3996
查看>>
python第三十九课——面向对象(二)之初始化属性
查看>>
python学习笔记之函数装饰器
查看>>
FEM计算2D瞬态热传导方程
查看>>
四年时光,匆匆而过
查看>>