当前位置:网站首页>S12. Verify multi host SSH mutual access script based on key
S12. Verify multi host SSH mutual access script based on key
2022-07-02 23:47:00 【Raymond999999】
be based on key Verify multi host ssh visit
[[email protected] ~]# cat ssh_key.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-12-20
#FileName: ssh_key.sh
#URL: raymond.blog.csdn.net
#Description: ssh_key for CentOS 7/8 & Ubuntu 18.04/24.04 & Rocky 8
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
# be based on key Verify multi host ssh Visit each other
COLOR="echo -e \\033[01;31m"
END='\033[0m'
PASS=123456
# Set the last address of the network segment ,4-255 Between , The smaller the scan, the faster
END=254
IP=`ip a s eth0 | awk -F'[ /]+' 'NR==3{print $3}'`
NET=${IP%.*}.
os(){
OS_ID=`sed -rn '/^NAME=/[email protected]*="([[:alpha:]]+).*"[email protected]\1@p' /etc/os-release`
}
ssh_key_push(){
rm -f /root/.ssh/id_rsa
[ -e ./SCANIP.log ] && rm -f SCANIP.log
for((i=3;i<="$END";i++));do
ping -c 1 -w 1 ${NET}${i} &> /dev/null && echo "${NET}${i}" >> SCANIP.log &
done
wait
ssh-keygen -f /root/.ssh/id_rsa -P '' &> /dev/null
if [ ${OS_ID} == "CentOS" -o ${OS_ID} == "Rocky" ] &> /dev/null;then
rpm -q sshpass &> /dev/null || {
${COLOR}" install sshpass software package "${END};yum -y install sshpass &> /dev/null; }
else
dpkg -S sshpass &> /dev/null || {
${COLOR}" install sshpass software package "${END};apt -y install sshpass &> /dev/null; }
fi
sshpass -p ${PASS} ssh-copy-id -o StrictHostKeyChecking=no ${IP}
AliveIP=(`cat SCANIP.log`)
for n in ${AliveIP[*]};do
sshpass -p $PASS scp -o StrictHostKeyChecking=no -r /root/.ssh [email protected]${n}:
done
# hold .ssh/known_hosts Copy to all hosts , So that they don't need to enter carriage return when they visit each other for the first time
for n in ${AliveIP[*]};do
scp /root/.ssh/known_hosts ${n}:.ssh/
done
}
main(){
os
ssh_key_push
}
main
边栏推荐
- [ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
- MFC文件操作
- Compose 中的 'ViewPager' 详解 | 开发者说·DTalk
- 可知论与熟能生巧
- 【OJ】两个数组的交集(set、哈希映射 ...)
- 简述中台的常识
- leetcode 650. 2 keys keyboard with only two keys (medium)
- 【Proteus仿真】51单片机+LCD12864推箱子游戏
- How to maintain the brand influence of clothing enterprises
- Yolox enhanced feature extraction network panet analysis
猜你喜欢

What can I do after buying a domain name?

C# MVC创建一个视图摆脱布局的影响

JSON数据传递参数

Mapper代理开发

67页新型智慧城市整体规划建设方案(附下载)

RTP 接发ps流工具改进(二)

Detailed explanation of 'viewpager' in compose | developer said · dtalk

Highly available cluster (HAC)

采用VNC Viewer方式远程连接树莓派
![[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)](/img/93/dc940caebe176177e4323317ebf4fa.jpg)
[error record] the flutter reports an error (could not resolve io.flutter:flutter_embedding_debug:1.0.0.)
随机推荐
Use of cocospods
2022 latest and complete interview questions for software testing
Arduino - 字符判断函数
返回二叉树中最大的二叉搜索子树的根节点
Convolution和Batch normalization的融合
【ML】李宏毅三:梯度下降&分类(高斯分布)
I've been interviewed. The starting salary is 16K
简述中台的常识
Returns the size of the largest binary search subtree in a binary tree
请求与响应
富滇银行完成数字化升级|OceanBase数据库助力布局分布式架构中台
返回二叉树两个节点间的最大距离
List of major chip Enterprises
Matlab 信号处理【问答笔记-1】
Realization of mask recognition based on OpenCV
JDBC Exercise case
Mapper代理开发
[Verilog tutorial]
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
Leetcode DP three step problem