Host Server1
User root
HostName 192.168.100.10
Host Server2
User root
HostName 192.168.100.5
Host Server3
User root
HostName 192.168.100.2
ProxyJump Server1, Server2
#!/bin/sh
/usr/bin/expect <<EOF
spawn ssh -F my.conf Server3
expect "password"
send "PASSWORD-OF-SERVER-1\r"
expect "password"
send "PASSWORD-OF-SERVER-2\r"
expect "password"
send "PASSWORD-OF-SERVER-3\r"
expect "$"
interact
EOF
$ server3.sh
Good reference: https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts