I want to be able to log in remotely to the router using an SSH connection using an 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 a couple of 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? What was wrong?