Monday, May 6, 2024
36
rated 0 times [  36] [ 0]  / answers: 1 / hits: 18724  / 1 Year ago, sat, december 24, 2022, 8:29:50

Sorry for the language mistakes I've made.
I'm trying to prevent vagrant asking the password when it mounts shared folders by NFS:



 [server] Exporting NFS shared folders...
Preparing to edit /etc/exports. Administrator privileges will be required...
[sudo] password for timur: #!!!


I've red many online resources like github and other author's posts, but nothing work for me...



I tried the instructions was found here. I don't have deep cli working knowledge. So could anybody give correct solution for my problem?


More From » command-line

 Answers
1

The official Vagrant docs now cover this:
https://www.vagrantup.com/docs/synced-folders/nfs.html#root-privilege-requirement



You need to add entries to the /etc/sudoers file, and the way to edit that is to type this at the terminal: sudo visudo



Type your password, and you're editing the file.
You'll want to paste these lines below (depending on whether you are running Vagrant on OS X or Linux.



If you're not familiar with vim, which it opens in, this page helped. Basically, copy the appropriate block of text below. Then, in visudo, go to the spot you want to paste text into the file (the end of the file is fine), and hit "i" to go into insert mode. CMD+V to paste your text. Then, hit ESC, then type :w to save your changes and then :q to quit.



As of version 1.7.3, the sudoers file in OS X should have these entries:



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


And Linux should have these entries:



Cmnd_Alias VAGRANT_EXPORTS_CHOWN = /bin/chown 0:0 /tmp/*
Cmnd_Alias VAGRANT_EXPORTS_MV = /bin/mv -f /tmp/* /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /etc/init.d/nfs-kernel-server status
Cmnd_Alias VAGRANT_NFSD_START = /etc/init.d/nfs-kernel-server start
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
%sudo ALL=(root) NOPASSWD: VAGRANT_EXPORTS_CHOWN, VAGRANT_EXPORTS_MV, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY


Note that these change from one version of Vagrant to another, so the above might be outdated. The important thing is that the docs now cover it.


[#27229] Sunday, December 25, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ticrew

Total Points: 190
Total Questions: 111
Total Answers: 99

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
;