当前位置:网站首页>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
边栏推荐
- 95页智慧教育解决方案2022
- List of major chip Enterprises
- Connexion à distance de la tarte aux framboises en mode visionneur VNC
- Intranet penetration | teach you how to conduct intranet penetration hand in hand
- Writing of head and bottom components of non routing components
- How to apply for company email when registering in company email format?
- Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]
- 35页危化品安全管理平台解决方案2022版
- yolov5test. Py comment
- 容器运行时分析
猜你喜欢

Container runtime analysis

数据集-故障诊断:西储大学轴承的各项数据以及数据说明

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

接口差异测试——Diffy工具

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

附加:token;(没写完,别看…)

JSON data transfer parameters

面试过了,起薪16k

Intranet penetration | teach you how to conduct intranet penetration hand in hand

Writing of head and bottom components of non routing components
随机推荐
JDBC练习案例
Convolution和Batch normalization的融合
How to apply for company email when registering in company email format?
Go project operation method
Bean load control
Returns the size of the largest binary search subtree in a binary tree
CDN acceleration requires the domain name to be filed first
Go basic anonymous variable
Detailed explanation of 'viewpager' in compose | developer said · dtalk
[array] binary search
sourcetree 详细
接口自动化覆盖率统计——Jacoco使用
QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
Returns the root node of the largest binary search subtree in a binary tree
MFC 获取当前时间
A single element in an ordered array -- Valentine's Day mental problems
Fusion de la conversion et de la normalisation des lots
vim区间删行注释
RuntimeError: no valid convolution algorithms available in CuDNN