SSH项目利用shell脚本实现密钥的批量分发与执行
ssh密钥的批量分发
- 开始安装sshpass免交互工具并进行SSH-key的批量分发
下载epel源并更新yum仓库
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y clean all
yum makecache
- 安装sshpass工具
yum -y install sshpass
创建密钥文件
- 免交互创建密钥对
root@ansible-1:~#:ssh-keygen -t dsa -f ~/.ssh/id_dsa -P ""
Generating public/private dsa key pair.
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.