Skip to content

Instantly share code, notes, and snippets.

@bdlangton
Created March 4, 2020 22:10
Show Gist options
  • Save bdlangton/95673986e3c7e782d29299ad5f7aa0e4 to your computer and use it in GitHub Desktop.
Save bdlangton/95673986e3c7e782d29299ad5f7aa0e4 to your computer and use it in GitHub Desktop.
Don't require password for vagrant commands
Type: sudo visudo
Add the following to the end of the file:
# Set these vagrant commands so that they don't require entering a password.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment