I have an Ubuntu VM that is connected to a VPN (using OpenConnect on Ubuntu), and I want to SSH from my OS X host to the VPN through Ubuntu:
(osx_host) --ssh--> (ubuntu_vm) --ssh--> (remote_server_on_vpn)
I've tried using SSH port forwarding with the commands below to forward Ubuntu's port 9922 to the remote server's port 22 such that SSH'ing to Ubuntu's port 9922 would connect to the remote server, but I'm getting unexpected results.
osx_host$ ssh -R 9922:remote_server_on_vpn:22 ubuntu_vm osx_host$ ssh localhost -p 9922
ubuntu_vm$ ssh -L 9922:remote_server_on_vpn:22 localhost osx_host$ ssh ubuntu_vm -p 9922
But these only open a shell to Ubuntu and not the remote server.
ubuntu_vm$ ssh -D localhost:9922 remote_server_on_vpn osx_host$ ssh ubuntu_vm -p 9922
but the connection to port 9922 times out. I've already verified that my
AllowTcpForwarding yes and rebooted. What am I doing wrong?