Created
May 17, 2018 14:23
-
-
Save wavezhang/21a8d178dd2092720aeff8b70dd8f423 to your computer and use it in GitHub Desktop.
init ssh key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum install -y expect | |
chmod +x ssh-copy-id.exp | |
for i in `seq 12 25`; do | |
./ssh-copy-id 192.168.1.$i root 'password' | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set user [lindex $argv 1] | |
set ip [lindex $argv 0] | |
set password [lindex $argv 2] | |
spawn ssh-copy-id $user@$ip | |
expect { | |
"*yes/no" { send "yes\r"; exp_continue} | |
"password" { send "$password\r" } | |
} | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment