推送公钥

it2022-05-05  159

#!/usr/bin/env bash>ip.txt

rpm -q expect &>/dev/nullif [ $? -ne 0 ];then yum -y install expectfi

if [ ! -f /root/.ssh/id_rsa.pub ];then ssh-kengen -P "" -f /root/.ssh/id_rsafi

for i in `cat slave.txt`do { ping -c $i &>/dev/null if [ $? -eq 0 ];then echo "$i" >> ip.txt /usr/bin/expect <<-EOF set timeout 10 spawn ssh-copy-id $i expect { "yex/no" { send "yex\r"; exp_continue} "password:" { send "123456\r" } } expect eof EOF fi }&donewaitecho "finnish...."

转载于:https://www.cnblogs.com/DBA-tomzhao/p/8601907.html


最新回复(0)