bash - SSH connection requests password before password can be sent -
i have odd problem trying ssh connect remote device inside of script can send commands weirdly it's asking password ssh connection before can call expect command. snippet this:
#!/usr/bin/expect set pass="password" echo {$pass} ssh admin@10.3.0.1 -p 4118 #firewall device ip expect { "password: " {send '$pass\r'} }
and output this:
password password:
i have no idea why behaving way.
edit: i've applied changes suggested @glenn jackman, new code being:
#!/usr/bin/expect set pass "peak1234" puts "$pass" ssh admin@10.3.0.1 -p 4118 #firewall device ip expect "password :" send "$pass\r"
with these changes error:
set: variable name must begin letter.
you're confusing expect sh
#!/usr/bin/expect set pass "password" ; ## no "=" puts $pass ; ## no "echo", braces wrong ssh admin@10.3.0.1 -p 4118 expect "password: " send "$pass\r" ; ## single quotes have no meaning in expect/tcl
Comments
Post a Comment