Automate SSH using expect script

#!/usr/bin/expect -f
set pass "password"
set server "hostname"
set user "username"
set port "27308"
set timeout 2
spawn ssh $user@$server -p $port
expect "RSA key fingerprint" { send "yes\r" }
expect "?assword:*" { send "$pass\r" }
send -- "\r"
interact
view raw login_ssh.sh hosted with ❤ by GitHub