Skip to content

Instantly share code, notes, and snippets.

@wavezhang
Created May 17, 2018 14:23
Show Gist options
  • Save wavezhang/21a8d178dd2092720aeff8b70dd8f423 to your computer and use it in GitHub Desktop.
Save wavezhang/21a8d178dd2092720aeff8b70dd8f423 to your computer and use it in GitHub Desktop.
init ssh key
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
#!/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