当前位置:网站首页>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
边栏推荐
猜你喜欢

最好用的信任关系自动化脚本(shell)

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

园区运营效率提升,小程序容器技术加速应用平台化管理

Mnasnet learning notes
![[exsi] transfer files between hosts](/img/c3/128b72aca6e030b2d4be2b6bddbc43.png)
[exsi] transfer files between hosts
![Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]](/img/83/e3c9d8eda9d5351d4c54928d3b090b.png)
Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]

Huawei operator level router configuration example | BGP VPLS configuration example

几行事务代码,让我赔了16万

Dell server restart Idrac method

Restcloud ETL WebService data synchronization to local
随机推荐
彻底解决Lost connection to MySQL server at ‘reading initial communication packet
Mouse over effect 10
Redis分布式锁的8大坑
Mysql知识点
ssh配置免密登录时报错:/usr/bin/ssh-copy-id: ERROR: No identities found 解决方法
[linear DP] longest common subsequence
鼠标悬停效果四
[applet project development -- Jingdong Mall] user defined search component of uni app (Part 1)
Metadata in NFT
Restcloud ETL data realizes incremental data synchronization through timestamp
PTA 1017
鼠标悬停效果六
Communication protocol -- Classification and characteristics Introduction
LeetCode_栈_困难_227.基本计算器(不含乘除)
Servlet [first introduction]
联想X86服务器重启管理控制器(XClarity Controller)或TSM的方法
Magnetic manometer and measurement of foreign coins
Mouse over effect I
Lenovo x86 server restart management controller (xclarity controller) or TSM method
鼠标悬停效果九