Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can user vagrant do "sudo su -" without entering password?

Tags:

vagrant

sudo

I am a new student about vagrant. I just found that I can change to root by "sudo su -" without entering a password when inside the box supervised by Vagrant. Curiously I checked the "/etc/sudoers" and found nothing about user vagrant. Can anyone kindly explain this?

like image 961
Vincentge Avatar asked May 25 '15 06:05

Vincentge


People also ask

Does sudo always ask for password?

If your timestamp_timeout is zero, sudo always prompts for a password. This feature can be enabled only by the superuser, however. Ordinary users can achieve the same behavior with sudo -k, which forces sudo to prompt for a password on your next sudo command.


2 Answers

/etc/sudoers include another file which contains the NOPASSWD line.

vagrant@ubuntu-12:~$ sudo cat /etc/sudoers.d/vagrant 
%vagrant ALL=NOPASSWD:ALL
like image 119
moodh Avatar answered Oct 23 '22 15:10

moodh


Based on http://docs.vagrantup.com/v2/boxes/base.html: "Many aspects of Vagrant expect the default SSH user to have passwordless sudo configured. This lets Vagrant configure networks, mount synced folders, install software, and more."

As moodh mentioned,

vagrant ALL=(ALL) NOPASSWD: ALL

will allow "password-less" sudo.

like image 40
Hicham El Hammouchi Avatar answered Oct 23 '22 13:10

Hicham El Hammouchi