0

I'm trying to Vagrant-ify a project in order to simplify dependency setup for my users. One of the dependencies is an SSH tunnel, from port A on host B to port C, using ssh's -L option.

I can successfully use the tunneling command ssh -L <A>:<B>:<C> on my host computer, and I would like to be able to do this in a Vagrant VM.

I have already successfully configured Vagrant to do ssh agent forwarding, in order to use the host's ssh keys to authenticate to private git repositories. But here I've reached the end of my knowledge of ssh and Vagrant when it comes to agent forwarding the tunnel. Is such a thing even possible?

  • is vagrant really relevant? can't you try to do this without any virtual machine? that is basic troubleshooting. And show the command and error you are getting. If it's private IP addresses like 192.168 or 10.1.2.3 or 172.16 etc then you can post that no risk. Or change the private IP to some other private IP if you're really worried. And change the port to some other port when you post.. if you're concerned about that. But good to show the actual command and error – barlop Mar 5 '14 at 23:06
  • I can successfully ssh tunnel directly from my host machine, but I want to be able to do this from a VM, using my host's credentials. Yes, Vagrant is relevant. – apennebaker Mar 14 '14 at 14:08
1

Turns out the keys were being forwarded, but ssh was using the vagrant username instead of the host username. When I corrected the username, ssh tunneling began working in Vagrant.

0

You don't tell if the tunnel should be made from host to guest or other way around, and where is B, and why can't you access it directly...

If you want to make a tunnel from some of the host's interfaces to the guest, you can use Vagrant's builtin port forwarding. Or just add private network address to the VM.

If you want to get tunnel from guest via the host, use ssh -R instead of ssh -L from the host. But in most cases you can just connect to the destination directly from the VM.

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.