#!/bin/sh

#tangbo

#QQ 79313760

######################################

######################################

#########install expect###############

yum -y install expect* >> /dev/null

############span rsa##################

ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa 

cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keyis 

chmod go-rwx /root/.ssh/authorized_keyis  


auto_ssh_copy_id () {


    expect -c "set timeout -1; 

                spawn ssh-copy-id $2;

                expect {

                    *(yes/no)* {send -- yes\r;exp_continue;}

                    *password:* {send -- $1\r;exp_continue;}

                    eof        {exit 0;}

                }";

}


auto_ssh_copy_id 111111 192.168.11.32 

                 #密码+IP