Linux????????????????
???????????? ???????[ 2015/6/1 13:19:10 ] ??????????????
????##### ????????ssh????? #####
?????????????expect?????yum????
????????????????ssh?????
batch_sshkey.sh
==============================================================
#!/bin/bash
cd /root
cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys
for i in `cat ip.txt`
do
ip=$(echo "$i"|cut -f1 -d":")
password=$(echo "$i"|cut -f2 -d":")
expect -c "
spawn scp /root/.ssh/authorized_keys /root/remote_operate.sh root@$ip:/tmp/
expect {
"*yes/no*" {send "yes
"; exp_continue}
"*password*" {send "$password
"; exp_continue}
"*Password*" {send "$password
";}
}
"
expect -c "
spawn ssh root@$ip "/tmp/remote_operate.sh"
expect {
"*yes/no*" {send "yes
"; exp_continue}
"*password*" {send "$password
"; exp_continue}
"*Password*" {send "$password
";}
}
"
done
============================================================
ip.txt???????IP??????????????e??????
192.168.8.23:123456
192.168.8.24:456789
============================================================
remote_operate.sh
#!/bin/bash
if [ ! -d /root/.ssh ];then
mkdir /root/.ssh
fi
cp /tmp/authorized_keys /root/.ssh/
==========================================================
????????batch_sshkey.sh???ɡ?
????batch_sshkey.sh??????????????./??У???й????????譴????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11