Does anyone have a clear step-by-step guide for setting up a shared tmux session on a Vagrant vbox that my coworkers (on our local office lan) could SSH into? The articles I've found online only seem to cover setting this up from machine to machine (no virtualbox setups), and I'm not very good at networking, so I haven't been able to extrapolate a solution...

We're all running the latest Macs in our office, btw.

Here's one article I've found but haven't been able to get working with Vagrant: http://blog.voxdolo.me/remote-pairing-with-vim-and-tmux.html

EDIT: To clarify, I don't really know how I should be setting up Vagrant to allow me to SSH into it from a machine outside the one hosting the VM. The article above suggests that I add the tunnels host on my physical machine running the VM (here-on referred to as the MBP), so I did that. Next is the ProxyCommand host declaration, which I have also assumed should live on the MBP.

So next I try SSHing into the MBP from a guest machine (another separate physical machine on my network), and that seems to work... but that only gets me into the MBP, not the Vagrant image running on the MBP.

I normally login Vagrant image on the MBP via vagrant ssh (per the docs), and I know how to forward ports on the Vagrant VM to the MBP, but it's unclear to me how I could forward ports/SSH from the MBP to the Vagrant VM, which I assume I would need to do so that my guest machine could SSH in--through the MBP--to my Vagrant image.

That, in a nutshell, is what I'm trying to accomplish. I do my development work in Vagrant VMs which keeps my MBP nice and clean of any dev-related cruft and also keeps my dev environments totally isolated from one another, yet I would like to start pair-programming with my coworkers via tmux, thus the reason why I've asked this question.

I would like to accomplish all of this without setting up an additional user account on the MBP, or giving my coworkers access to my local user account on the MBP to get to my Vagrant VM, if that's at all possible.

UPDATE: Been trying to setup a bridged connection, per @John Whitley's suggestion, and I've been unsuccessful so far.

I have a new network adapter on my vagrant image set to bridged, tied to my AirPort interface on my host computer:

vbox manager

I then can vagrant ssh into the box and run ifconfig and see that it as the IP of

ifconfig on vagrant box

But when I open up a new terminal session on my host machine and try to ping that address, I don't get anything:


I noticed that the Vagrant docs, on the section for bridged networking (http://vagrantup.com/v1/docs/bridged_networking.html), seem to list the bridged device as eth2 and have an elipses before that, suggesting that there might also be an eth1 device active with a different IP. My ifconfig on the vagrant box doesn't have two separate adapters. I am prompted when booting up the vagrant image:

prompt for bridged network interface

To which I always reply 1 for my Airport, which I assume I should be doing. Any thoughts on getting this working? My Vagrant box can still talk out to the internet, and port forwarding still works...

  • 1
    More details, please. We don't know how it doesn't work for you or even at which step you are blocked. What works? What doesn't? Can you even SSH into one of those VMs? Did you talk to the IT department? – romainl Jun 14 '12 at 4:28
  • Well, tmux sessions are shared by default, so that part should not pose a problem. Just connect to it normally from multiple locations. – Daniel Andersson Jun 14 '12 at 8:01
  • @romainl See my update; did my best to explain what I've tried so far. Again, SSH beyond the basics is not my forte... – neezer Jun 14 '12 at 15:57

The easiest thing to do is to add a Bridged network interface to your Vagrant VM. (Don't change the primary network interface to Bridged interface, per the Vagrant docs.) A NAT interface has access to the external network (e.g. so the VM can pull packages, git repos, etc.), but the external network can't access the VM. NAT-only is the default Vagrant network setup. In the VirtualBox Manager GUI, it'll look like this:

NAT interface in VirtualBox GUI

A VirtualBox Bridged interface appears to the external network just as a real physical host would -- including acquiring an IP from the local DHCP server, and getting a domain name assigned via DDNS if the local network it setup for that. This means you can just check the VM's IP address (e.g. via vagrant ssh -c ifconfig) and ssh directly into it. Again, a screencap of the VB GUI:

Bridged interface in VirtualBox GUI

The VirtualBox Networking Docs cover the various "flavors" of interfaces supported by the VM environment, including some not covered here. It's fairly short and well worth a read.

The final bit of magic is configuring the VirtualBox VM properly. In your Vagrantfile, you'll need to add a line like so:

config.vm.network :bridged

vagrant reload is needed after that change to put it into effect. See the Vagrant bridged networking docs for more details on this method.

| improve this answer | |
  • I had setup my base box to use NAT instead of Bridged because of this snippet from the Vagrant docs (vagrantup.com/v1/docs/base_boxes.html): "Now this is really important: Make sure the network controller is set to NAT. For port forwarding to work properly, NAT must be used. Bridged connects are not supported since it requires the machine to specify which device it is bridged to, which is unknown." Am I just losing port forwarding on my VM to localhost if I do this (and instead have to resolve the IP of the VM in my browser instead)? – neezer Jun 22 '12 at 22:21
  • That note about NAT w/ Vagrant is correct, thanks. I've corrected and clarified the text above to indicate that a Bridged interface should be added to the VM, not replace the NAT. A default sshd installation will bind port 22 on all interfaces, so you can still ssh in and fire up tmux via the added Bridged interface. – John Whitley Jun 23 '12 at 18:28
  • Hey @john, see my update above; I haven't been able to get this work, which has been frustrating, since I feel like it should be pretty simple and straightforward. I'd appreciate any additional insight you could give me! – neezer Jun 24 '12 at 1:46
  • So I determined that this does work fine with the official vagrant boxes found here: github.com/mitchellh/vagrant/wiki/Available-Vagrant-Boxes. All you need to do is config.vm.network :bridged as you pointed out. Will have to figure out why my other custom box wasn't working... thanks. – neezer Jun 29 '12 at 20:59
  • @neezer, as a wild guess, you might look at the sshd config on the non-working box. It might be that it's binding port 22 on only one interface? I'd log into the VM via vagrant ssh and poke around to see what's bound to port 22(sshd) via sudo netstat -a -p on the box. – John Whitley Jul 2 '12 at 19:35

Over NAT you can connect with this:

ssh -p 2222 vagrant@[IP address of your host machine]

If your host machine is under a proxy, forward port 2222 to the Internet.

| improve this answer | |

Anyone with this issue might want to consider wemux: https://github.com/zolrath/wemux

From the README:

If you have Homebrew installed you can install wemux with a fairly simple:

brew install https://github.com/downloads/zolrath/wemux/wemux.rb

The user that installed wemux will automatically be added to the wemux host list. To change the host or add more hosts, edit /usr/local/etc/wemux.conf and add the username to the host_list array.

Users in the host_list will be able to start new wemux servers, all other users will be wemux clients and join these servers.

$ vim /usr/local/etc/wemux.conf


$ wemux conf

host_list=(zolrath brocksamson)
| improve this answer | |

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.