SSH into Vagrant using a private ip


I've recently been looking at using netcat and also understanding how SSH tunelling works. In order to play around with tunelling specifically, I needed an environment that I could SSH into (e.g. so I could proxy a connection through to).

My initial thought was to use Docker and setting it up with an SSH daemon. Annoyingly I couldn't get it to let me SSH into the running Docker container. So due to a lack of time allowance dedicated to this problem, I decided to work around this by using Vagrant instead.


Now Vagrant automatically sets you up with a vagrant ssh command, but I still needed an actual dedicated ip that I could use to SSH into the running Vagrant VM. So the solution requires the following items:



Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| = "ubuntu/trusty64" "private_network", ip: ""

As you can see, we're building a Ubuntu 14.04.2 VM, and we've defined a private ip address (; although this could be any private ip range (e.g. instead.

Note: as noted by Simon Thulbourn 192.168/16 is used more for home/small networks

SSH Config

  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  IdentitiesOnly yes
  User vagrant
  IdentityFile /path/to/user/directory/vagrant-ssh/.vagrant/machines/default/virtualbox/private_key
  PasswordAuthentication no

Note: the IdentityFile value can be retrieved from vagrant ssh-config


Now we have the set-up in place, we can build the VM:

vagrant up --provider virtualbox

Once the VM is created and running we can SSH into the box directly using our defined private ip:

ssh -F ./ssh-config vagrant@