Passwordless NFS with Vagrant

Wouter Peschier • November 5, 2016

vagrant macos

Getting tired of having to type your password every time you start up your Vagrant box? Well, I have good news for you because there is a solution for that.

$ sudo visudo

If you are on a Mac you can add the following lines:

# Allow passwordless startup of Vagrant when using NFS.
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

Other operating systems might need some other commands but the idea is the same.