I want to be able to login remotely to the router using SSH connection using expect script, and this is what I have:
#!/usr/bin/expect
set host "192.168.1.50"
set user "root"
set password "mypass"
spawn ssh "$user\@host"
expect "word:"
send "$password\r"
When I tried to use that, the router became unresponsive (and possibly timed out). When it went to password prompt line, it immediately went back out.
I did authentication using my SSH key by manually typing "yes" when it prompted me with "yes/no" questions the first time I logged in. Then, after the first try, the router just automatically prompted me with the password. To be exact, it has two lines:
User Authentication
Password:
Then after couple seconds it went back to my root as if the send command did not send anything after that password prompt.
So, my question, with my very limited knowledge about expect and scripting in general, is: what is the solution for this? Is there any idea what was wrong?