I'm trying to use the Expect in my Bash script to provide my SSH password. Providing the password works, but I am end up in some other SSH session. It goes back to the Bash.
My script:
#!/bin/bash
read -s PWD
/usr/bin/expect <<EOD
spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no usr@$myhost.example.com'
expect "password"
send "$PWD\n"
EOD
echo "you're out"
The output of my script:
spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no usr@$myhost.example.com
usr@$myhost.example.com's password: you're out
I want to have my SSH session only when I exit it and go back to my Bash script.
I wanted this because I have to use a menu. I wanted to choose which unit/device to connect to.