Vagrant with sshfs and public network

Vagrant with sshfs. You can use sshfs in vagrant with only a private network. This is fine if you are doing all your devlopment from a single machine and dont need to access the vagrant box from your network, but if you need to run some testing from an external machine (eg you have Kali on a laptop and want to perform an sqli scan) then you will need a public_network.

One advantage using sshfs over NFS is that you can boot vagrant machines from the same vagrant file in linux, osx and windows, meaning less maintenance and easier workflows.


1) install vagrant
2) install virtuabox
3) create a vagrant file
4) in the vagrant file use this pattern:
config.vm.synced_folder “.”, “/var/www/vhosts/”,
create: true,
type: ‘sshfs’
5) install sshfs in vagrant
vagrant plugin install sshfs
6) vagrant up

Vagrant with sshfs and public_network is a great way to share directories from your host machine with your vagrant box – you can edit code and it is instantly reflected inside your vagrant environment, allowing for very fast development time and testing of ideas / branching / debugging, etc.

Fortunately you can define more than one network in a vagrant machine (as you can in a real machine).

# original private_network "private_network", ip: "" "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: ""

This will add two networks to your vagrant machine. You can then add multiple sshfs shares.

I use the following config to share my devops scripts (which have their own git repo) with my vagrant machine and also have my current project shared inside vagrant. In work we have a shared config that has 5 or 6 different projects – system wide libraries, current project, shared unit tests, test data repo, devops helper code, etc

Vagrant with NFS and public_network

# share the current folder in /var/www/vhosts/development
    config.vm.synced_folder ".", "/var/www/vhosts/development", 
    create: true, 
    type: 'sshfs'

    # share another folder
    config.vm.synced_folder "~/devops", "/var/www/vhosts/devops",
    create: true, 
    type: 'sshfs'

I hope you enjoyed my Vagrant with sshfs and public_network tutorial – you might like my post on DVWA in a vagrant box.

Leave a Reply