批量實(shí)現(xiàn)自動(dòng)發(fā)送公鑰到遠(yuǎn)程主機(jī)
創(chuàng)新互聯(lián)是一家專業(yè)提供伊春企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、H5頁(yè)面制作、小程序制作等業(yè)務(wù)。10年已為伊春眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計(jì)公司優(yōu)惠進(jìn)行中。
firewalld:關(guān)閉
selinux:關(guān)閉
#!/bin/bash
#
#********************************************************************
#Author: hechunping
#QQ: ×××
#Date: 2019-11-07
#FileName: ssh-sshpass.sh
#URL: hexiaoshuai.blog.51cto.com
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
NET=172.20.200
USER=(root hechunping)
PASSWORD=123456
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa &> /dev/null
sed -i '/StrictHostKeyChecking/c StrictHostKeyChecking no' /etc/ssh/ssh_config
rpm -q sshpass &> /dev/null || yum -y install sshpass &> /dev/null
for i in {1..254} ; do
{
sshpass -p $PASSWORD ssh-copy-id -i ${USER[0]}@${NET}.${i} &> /dev/null
}&
done
wait
#!/bin/bash
#
#********************************************************************
#Author: hechunping
#QQ: ×××
#Date: 2019-11-07
#FileName: ssh-expect.sh
#URL: hexiaoshuai.blog.51cto.com
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
NET=172.20.200
USER=(root hechunping)
PASSWORD=123456
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa &> /dev/null
for i in {1..254} ; do
{
expect <