当前位置:网站首页>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
边栏推荐
- Implementation of VGA protocol based on FPGA
- Master the development of facial expression recognition based on deep learning (based on paddlepaddle)
- Go basic anonymous variable
- 顶级 DevOps 工具链大盘点
- 接口差异测试——Diffy工具
- 基于Pyqt5工具栏按钮可实现界面切换-2
- Installing redis under Linux
- Interface switching based on pyqt5 toolbar button -2
- Interface switching based on pyqt5 toolbar button -1
- Bean加载控制
猜你喜欢

QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)

Implementation of VGA protocol based on FPGA

35页危化品安全管理平台解决方案2022版

Request and response

How much do you know about synchronized?

"A good programmer is worth five ordinary programmers!"

MySQL Foundation

(stinger) use pystinger Socks4 to go online and not go out of the network host

Go basic anonymous variable

Fusion de la conversion et de la normalisation des lots
随机推荐
YOLOX加强特征提取网络Panet分析
CDN acceleration requires the domain name to be filed first
Installing redis under Linux
How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
流媒体技术优化
Bean load control
Which common ports should the server open
JSON data transfer parameters
MySQL基础
顶级 DevOps 工具链大盘点
CADD课程学习(4)-- 获取没有晶体结构的蛋白(SWISS-Model)
The privatization deployment of SaaS services is the most efficient | cloud efficiency engineer points north
leetcode 650. 2 keys keyboard with only two keys (medium)
ArrayList分析2 :Itr、ListIterator以及SubList中的坑
理想汽车×OceanBase:当造车新势力遇上数据库新势力
Interface switching based on pyqt5 toolbar button -1
Use of cocospods
Fusion de la conversion et de la normalisation des lots
数据集-故障诊断:西储大学轴承的各项数据以及数据说明
ArrayList analysis 2: pits in ITR, listiterator, and sublist