1

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.

Trial 1

osx_host$ ssh -R 9922:remote_server_on_vpn:22 ubuntu_vm
osx_host$ ssh localhost -p 9922

Trial 2

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.

Trial 3

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 /etc/ssh/sshd_config contains AllowTcpForwarding yes and rebooted. What am I doing wrong?

1

The command should be

osx_host$ ssh -fNL 9922:remote_server_on_vpn:22 ubuntu_vm
osx_host$ ssh localhost -p 9922

Remember to end existing connections.

  • This does not work – tony19 Aug 16 '14 at 18:20
  • @superuser how? Connection refused? Timed out? – muru Aug 16 '14 at 18:26
  • It results in the same behavior as Trials 1 and 2 (connects to ubuntu_vm rather than the remote server). – tony19 Aug 16 '14 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.