Passwordless NFS with Vagrant

November 5, 2016 by Wouter Peschier

vagrant macos

Getting tired of having to type your password every time you start up your Vagrant box? It's pretty annoying, you start up your Vagrant box and walk away to get a coffee only to come back to a prompt waiting for you to enter your password. You can use visudo to allow the commands to be run without having to enter a password.

$ 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

Depending on you operating system you might need to add some other commands, but the idea is the same.