valkyrie-sshfs

A Vagrant plugin to mount a folder from the box to the host (or vice-versa) using sshfs.

This is a fork of the vagrant-sshfs plugin, with a couple tweaks for use on Valkyrie.

Why

Common solutions for sharing folders with Vagrant include synced folder, which is pretty slow when dealing with many files, and NFS. NFS didn't work for us since it limits one's ability to change file permissions and ownership. An alternative was to mount a folder in the host machine pointing to a folder in the box with sshfs.

Installation

vagrant plugin install valkyrie-sshfs

Usage

In the Vagrantfile, add a configuration like this:

config.vsshfs.paths = { "src" => "mountpoint" }

src is the source absolute path to the folder in the box, mountpoint is the folder in the host machine. mountpoint can be an absolute path, or relative to the Vagrantfile.

By default it will use the Vagrant ssh username. You can change that with the following:

config.vsshfs.username = "theusername"

The plugin is enabled by default, so it will run everytime the machine starts. In case that is not desired, you can disabled that with the following configuration:

config.vsshfs.enabled = false

To manually run it, you can use the vsshfs command. Please check vagrant -h.

Issues

Connection reset by peer

In case you are getting "Connection reset by peer" errors, it might be the case that you already have a host configuration under your ~/.ssh/know_hosts for the given ip, and you are using the same ip with a different machine. If that is the case, you can set a StrictHostKeyChecking no under that ip to skip the check:

Host 127.0.0.1
StrictHostKeyChecking no

Mounting on guest (box)

You need to have sshfs installed on guest machine and ssh server on host.

To mount a host folder on guest machine add a configuration like this:

config.vsshfs.mount_on_guest = true
config.vsshfs.paths = { "src" => "mountpoint" }
config.vsshfs.host_addr = '10.0.2.2'

src is the source absolute path to the folder in the host machine, mountpoint is the folder in the guest. src can be an absolute path, or relative to the Vagrantfile. host_addr is the host machine IP accessible from guest.

Contributing

If you have issues or ideas, please contribute! You can create an issue throught Github, or send a Pull Request.

Development

To try this out, you can run bundle exec vagrant up from the source code checkout.