免密钥批量分发脚本

作者: admin 分类: Shell脚本 发布时间: 2021-04-19 16:28
#!/bin/bash
funA ()
{
/usr/bin/expect <<EOF
spawn ssh-keygen
expect ":"
send "\r"
expect ":"
send "\r"
expect ":"
send "\r"
expect eof
EOF
}
funB ()
{
/usr/bin/expect <<EOF
spawn ssh-copy-id 10.1.1.$i     #ip地址段
expect "yes/no"
send "yes\r"
expect "password"
send "123456\r"
expect eof
EOF
}
yum -y install expect
funA
for i in {30..34}       #ip末尾数
do
funB
done

温馨提示:如无特殊说明,本站文章均为作者原创,转载请注明出处!

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论