当前位置:网站首页>Best used trust automation script (shell)
Best used trust automation script (shell)
2022-07-01 03:03:00 【Avenue to Jane @everyday】
1, Create three files ,
2 father.txt Put the server that needs to establish trust relationship ip list , The format is as follows 
3 passwd.txt Is the login password of the server , All servers must have the same password , If it is different, it can be modified rsa.sh Script 
4 rsa.sh Script for establishing trust relationship
#!/bin/bash
#ssh-keygen -t rsa
basepath=$(cd `dirname $0`; pwd)
echo $basepath
father_file_name='father.txt'
# Generate the key
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
# Update for each machine hosts Documents and public key information
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
边栏推荐
- Saving images of different depths in opencv
- Big orange crazy blog move notice
- Why are strings immutable in many programming languages? [repeated] - why are strings immutable in many programming languages? [duplicate]
- Mouse over effect II
- xxl-job使用指南
- [PR # 5 A] two way running (state pressure DP)
- Mouse over effect 8
- Restcloud ETL data realizes incremental data synchronization through timestamp
- 如何校验两个文件内容是否相同
- Poj-3486-computers[dynamic planning]
猜你喜欢

xxl-job使用指南

Redis分布式锁的8大坑

Xception learning notes

Completely solve the lost connection to MySQL server at 'reading initial communication packet

MCU firmware packaging Script Software

Mysql知识点

产业互联网中,「小」程序有「大」作为

Cloud native annual technology inventory is released! Ride the wind and waves at the right time

servlet【初识】
![Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]](/img/83/e3c9d8eda9d5351d4c54928d3b090b.png)
Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]
随机推荐
Optimal transport Series 1
【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)
How do I hide div on Google maps- How to float a div over Google Maps?
Redis高效点赞与取消功能
Od modify DLL and exe pop-up contents [OllyDbg]
【EXSI】主机间传输文件
C language a little bit (may increase in the future)
Restcloud ETL practice data row column conversion
PHP batch Excel to word
SSH configuration password free login error: /usr/bin/ssh copy ID: error: no identities found solution
彻底解决Lost connection to MySQL server at ‘reading initial communication packet
Druid监控统计数据源
[applet project development -- JD mall] uni app commodity classification page (first)
Mouse over effect V
Prototype and prototype chain in JS
An article explaining the publisher subscriber model and the observer model
PCB defect detection based on OpenCV and image subtraction
[linear DP] longest common subsequence
几行事务代码,让我赔了16万
Is it safe to open a stock account? Shanghai stock account opening procedures.