当前位置:网站首页>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
边栏推荐
- SharedPreferences save list < bean > to local and solve com google. gson. internal. Linkedtreemap cannot be cast to exception
- Leetcode relaxation question - day of the week
- 95页智慧教育解决方案2022
- 附加:token;(没写完,别看…)
- 35页危化品安全管理平台解决方案2022版
- JSON数据传递参数
- Convolution和Batch normalization的融合
- 67页新型智慧城市整体规划建设方案(附下载)
- C MVC creates a view to get rid of the influence of layout
- A single element in an ordered array -- Valentine's Day mental problems
猜你喜欢

Realization of mask recognition based on OpenCV

CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)

Markdown basic grammar

Interface switching based on pyqt5 toolbar button -1

"A good programmer is worth five ordinary programmers!"

实用系列丨免费可商用视频素材库

Ideal car × Oceanbase: when the new forces of car building meet the new forces of database

接口差异测试——Diffy工具

Where is the win11 automatic shutdown setting? Two methods of setting automatic shutdown in win11

How much do you know about synchronized?
随机推荐
容器运行时分析
95页智慧教育解决方案2022
内网渗透 | 手把手教你如何进行内网渗透
基于FPGA的VGA协议实现
Brief introduction to common sense of Zhongtai
Remote connection of raspberry pie by VNC viewer
Which common ports should the server open
yolov5train. py
Three solutions to frequent sticking and no response of explorer in win11 system
How difficult is it to be high? AI rolls into the mathematics circle, and the accuracy rate of advanced mathematics examination is 81%!
Container runtime analysis
附加:token;(没写完,别看…)
Load balancing cluster (LBC)
Intranet penetration | teach you how to conduct intranet penetration hand in hand
开发知识点
Codeforces Round #771 (Div. 2)---A-D
MySQL Foundation
C# MVC创建一个视图摆脱布局的影响
C MVC creates a view to get rid of the influence of layout
How much do you know about synchronized?