当前位置:网站首页>最好用的信任关系自动化脚本(shell)
最好用的信任关系自动化脚本(shell)
2022-07-01 02:56:00 【大道至简@EveryDay】
1,创建三个文件,
2 father.txt 放需要建立信任关系的服务器ip列表,格式如下
3 passwd.txt 为服务器的登录密码,要求所有服务器的密码一样,如果不一样可以修改rsa.sh脚本
4 rsa.sh 为建立信任关系的脚本
#!/bin/bash
#ssh-keygen -t rsa
basepath=$(cd `dirname $0`; pwd)
echo $basepath
father_file_name='father.txt'
#生成密钥
if [ ! -f ~/.ssh/id_rsa ] ; then
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
fi
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
pw=`cat $basepath/passwd.txt`
op_flag=$2
#更新各机器的hosts文件及公匙信息
for HOSTNAME in `cat ${basepath}/${father_file_name}| grep -v '127.0.0.1'| grep -v '::1'|awk '{print $1}'`
do
{
sleep 2
mycommand="ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]${HOSTNAME}"
expect -c "
spawn ${mycommand};
set timeout 60
expect {
\"password:\" {send \"${pw}\r\"; exp_continue}
\"connecting (yes/no)?\" {send \"yes\r\"; exp_continue}
}
"
sleep 2
}&
done
wait
边栏推荐
- 股票开账户如何优惠开户?还有,在线开户安全么?
- Multithreaded printing
- xxl-job使用指南
- RestCloud ETL实践之无标识位实现增量数据同步
- Mouse over effect 9
- How to determine the progress bar loaded in the loading interface when opening the game
- MnasNet学习笔记
- Evaluation of the entry-level models of 5 mainstream smart speakers: apple, Xiaomi, Huawei, tmall, Xiaodu, who is better?
- 【小程序项目开发-- 京东商城】uni-app之分类导航区域
- 通信协议——分类及其特征介绍
猜你喜欢
彻底解决Lost connection to MySQL server at ‘reading initial communication packet
Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and
[applet project development -- JD mall] uni app commodity classification page (Part 2)
VMware vSphere 6.7虚拟化云管理之12、VCSA6.7更新vCenter Server许可
STM32 - DS18B20 temperature sampling of first-line protocol
Visual effects, picture to cartoon function
Xception学习笔记
Gartner研究:在中国,混合云的采用已成为主流趋势
Dell服务器重启iDRAC方法
MnasNet学习笔记
随机推荐
The operation efficiency of the park is improved, and the application platform management of applet container technology is accelerated
咱就是说 随便整几千个表情包为我所用一下
Big orange crazy blog move notice
基于Pytorch完整的训练一个神经网络并进行验证
A shooting training method based on the digital measurement of Joule energy and posture of sphygmomanometer air bag with standard air pressure
Youmeng (a good helper for real-time monitoring of software exceptions: crash) access tutorial (the easiest tutorial for Xiaobai with some foundation)
RestCloud ETL WebService数据同步到本地
Sampling Area Lights
servlet【初识】
Share Creators萌芽人才培養計劃來了!
Restcloud ETL WebService data synchronization to local
Poj-3486-computers[dynamic planning]
Restcloud ETL实践之数据行列转换
VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
PTA 1017
Prototype and prototype chain in JS
DenseNet网络论文学习笔记
Is it safe to open a stock account? Shanghai stock account opening procedures.
MnasNet学习笔记
Servlet [first introduction]