Tunnelling into your Chef Kitchen Vagrant instance

So you’ve just done this:

Shell

1

kitchen create default-centos-72

And now something has gone wrong on the box and you need to tunnel through to check something on your instance (say mysql database). Whatever the port may be, you need to change your current directory to where the vagrant file is. This can be achieved by running the following command relative to where your kitchen file is:

Shell

1

cd.kitchen/kitchen-vagrant/kitchen-default-centos72

List the directory and you will be able to see a Vagrantfile in it. Once you are there, run:

Shell

1

vagrant ssh---L3306:localhost:3306

Here I’m using mysql port 3306, you can replace it with whatever port you want to tunnel through.