#!/bin/expect ############################################################ # $Name: send_sshkey.exp # $Version: v1.0 # $Functions: # $Author: Jeson Li # $organization: www.lzbbg.cn # $Create Date: 2017-03-10 # $Mail: libobin@tom.com # $Description: This expect scripts is No interactive distribution key ############################################################ if { $argc != 5 } { send_user "usage: expect fenfa_sshkey.exp pub_key_file remote_user remote_passaword remote_ip\n" exit 3 } # defile variables set remote_Port [ lindex $argv 0 ] set remote_user [ lindex $argv 1 ] set remote_password [ lindex $argv 2 ] set remote_ip [ lindex $argv 3 ] set remote_dsa [ lindex $argv 4 ] spawn ssh-copy-id -i $remote_dsa -p $remote_Port $remote_user@$remote_ip expect { "yes/no" { send "yes\r";exp_continue } "*password" { send "$remote_password\r";exp_continue } }
浙公网安备 33010602011771号