作者: 薄荷冰           Linux基础  |  网站架构  |  数据库  |  监控报警  |  shell系列  |  常用工具  |  常见问题


 

导航

 
#!/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 }
 }

 

posted on 2018-12-27 20:19  薄荷冰  阅读(86)  评论(0)    收藏  举报