当前位置:网站首页>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
边栏推荐
- 接口差异测试——Diffy工具
- Use of cocospods
- Brief introduction to common sense of Zhongtai
- 返回二叉树中最大的二叉搜索子树的根节点
- leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
- Speech recognition Series 1: speech recognition overview
- leetcode 650. 2 keys keyboard with only two keys (medium)
- QT 如何将数据导出成PDF文件(QPdfWriter 使用指南)
- Solution: exceptiole 'xxxxx QRTZ_ Locks' doesn't exist and MySQL's my CNF file append lower_ case_ table_ Error message after names startup
- @How to use bindsinstance in dagger2
猜你喜欢

Wechat applet basic learning (wxss)

Go basic anonymous variable

基于FPGA的VGA协议实现

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

Program analysis and Optimization - 9 appendix XLA buffer assignment

CDN acceleration requires the domain name to be filed first

Maybe you read a fake Tianlong eight

JDBC练习案例

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

2022 latest and complete interview questions for software testing
随机推荐
Request and response
Returns the maximum distance between two nodes of a binary tree
可知论与熟能生巧
Convolution和Batch normalization的融合
vim区间删行注释
MarkDown基本语法
Returns the size of the largest binary search subtree in a binary tree
跨境电商如何通过打好数据底座,实现低成本稳步增长
Why can't the start method be called repeatedly? But the run method can?
Develop knowledge points
Optimization of streaming media technology
PHP get real IP
Interface switching based on pyqt5 toolbar button -1
程序分析与优化 - 9 附录 XLA的缓冲区指派
附加:token;(没写完,别看…)
基于FPGA的VGA协议实现
[OJ] intersection of two arrays (set, hash mapping...)
Speech recognition Series 1: speech recognition overview
How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
公司里只有一个测试是什么体验?听听他们怎么说吧