Monday, December 14, 2015

Expect to automate login in ssh or balabit

#!/usr/bin/expect -f

set force_conservative 0  ;# set to 1 to force conservative mode even if
              ;# script wasn't run conservatively originally
if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
        sleep .1
        exp_send -s -- $arg
    }
}

set timeout -1
spawn ssh -l user@target29  balabit_address
match_max 100000
expect -exact "Gateway username: "
send -- "seu_usuario_balabit_aqui\r"
expect -exact "seu_usuario_balabit_aqui\r
Gateway password: "
send -- "seu_password_balabit_aqui\r"
expect -exact "password: "
send -- "senha_do_maquina_target\r"
interact


Criar arquivo automaticamente conforme vai se digitando
autoexpect -f  arquivo_expect  ssh -l user@target29 balabit_address
Usar arquivo gerado
expect -f arquivo_expect



No comments:

Blog Archive