用shell脚本批量分发公钥,实现用…
2017-07-15 16:00
92 查看
用shell脚本批量分发公钥(将所有),先创建密钥分发expetc脚本key.exp
再创建shell脚本,调用expetc
1.vim ip.txt
10.1.1.1
10.2.2.2
10.3.3.3
2.key.exp
vim key.exp
#!/usr/bin/expetc
set timeout 300
set password "redhat"
set ip [lindex $argv 0]
spawn ssh-copy-id root@$ip
expetc{
"yes/no"{
send "yes\r"
exp_continue
}
"password: "{
send"password\r"
exp_continue
}
eof;
}
再创建shell脚本,调用expetc
3.
vim distribute.exp
#!/bin/bash
./etc/init.d/functions
for i in 'cat /root/ip.txt';do
expetc /root/key.exp $i>/dev/null 2>&1
if[$? -eq 0];then
action"$i" /bin/true
else
action "$i"/bin/false
fi
done
再创建shell脚本,调用expetc
1.vim ip.txt
10.1.1.1
10.2.2.2
10.3.3.3
2.key.exp
vim key.exp
#!/usr/bin/expetc
set timeout 300
set password "redhat"
set ip [lindex $argv 0]
spawn ssh-copy-id root@$ip
expetc{
"yes/no"{
send "yes\r"
exp_continue
}
"password: "{
send"password\r"
exp_continue
}
eof;
}
再创建shell脚本,调用expetc
3.
vim distribute.exp
#!/bin/bash
./etc/init.d/functions
for i in 'cat /root/ip.txt';do
expetc /root/key.exp $i>/dev/null 2>&1
if[$? -eq 0];then
action"$i" /bin/true
else
action "$i"/bin/false
fi
done
相关文章推荐
- LINUX用户建立秘钥认证实现SHELL脚本管理,分发,部署
- [置顶] 编写shell脚本以及利用函数实现批量安装Linux服务配置
- Expect--自动批量分发公钥脚本
- shell脚本实现批量自动redis反弹shell攻击
- shell中批量部署脚本实现
- 通过shell脚本实现批量更改密码
- Shell脚本实现批量添加用户
- linux下采用shell脚本实现批量为指定文件夹下图片添加水印的方法
- Shell脚本实现批量下载资源并保留原始路径
- [shell实例]——用脚本实现向多台服务器批量复制文件(nmap、scp)
- linux下采用shell脚本实现批量为指定文件夹下图片添加水印的方法
- 使用shell脚本实现php应用的批量更新
- Shell脚本实现批量下载资源并保留原始路径
- [工具] 分布式系统下批量创建用户及分发公钥打通ssh通道的脚本
- 免交互方式批量分发公钥脚本
- shell脚本实现anisble客户端脚本分发和密钥授权配置
- shell脚本中使用iconv实现批量文件转码的代码分享
- shell脚本中使用iconv实现批量文件转码
- Shell脚本实现批量下载网络图片代码分享