1
0

ref: 构建工具重构

This commit is contained in:
TsMask
2025-03-19 17:21:47 +08:00
parent f2e43b0fc4
commit b2f867b86c
211 changed files with 1047 additions and 105510 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# if exist id_rsa
if [ ! -f ~/.ssh/id_rsa ];then
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
else
echo "id_rsa has created ..."
fi
# distribute to hosts in file nehosts
while read line
do
# ignore comment or null line
if [[ "$line" =~ ^[^[:space:]]*# || -z "$line" ]]; then
continue
fi
ip=`echo $line | cut -d " " -f 1`
user=`echo $line | cut -d " " -f 2`
passwd=`echo $line | cut -d " " -f 3`
# !!! to remove ~/.ssh, all old authorized key will be lost
expect <<EOF
set timeout 10
spawn ssh $user@$ip "sudo rm -r ~/.ssh"
expect {
"yes/no" { send "yes\n";exp_continue }
"password:" { send "$passwd\n" }
}
spawn ssh-copy-id -f $user@$ip
expect {
"password:" { send "$passwd\n" }
}
expect eof
EOF
done < nehosts