黑猴子的家:auto-ssh-expect.sh

在/usr/local/bin 目录下

#!/bin/bash

user=`whoami`
passwd=000000

#yum install -y sshpass expect

for((current=102; current<=104; current++));do
    for((host=102; host<=104; host++));do
    sshpass -p $passwd ssh -q -o StrictHostKeyChecking=no $user@hadoop$current expect << EOF
    spawn ssh-copy-id ${user}@hadoop${host}
    expect {
        "yes/no" {send "yes\r";exp_continue}
        "password" {send "$passwd\r"}
    }
    expect eof
EOF
    done
done

你可能感兴趣的:(黑猴子的家:auto-ssh-expect.sh)