I have an user created in VagrantFile and whenever I run a command with sudo it asks for a password. I don't know what that password is, so I would appreciate some help on this matter
I have tried to set up the following without success:
config.ssh.username = "Sorin"
config.ssh.password = "6282"
config.ssh.insert_key = false
User created as following in Vagrantfile:
bootstrap = <<SCRIPT
useradd -m Sorin --groups sudo
su -c "printf 'cd /home/Sorin\nsudo su Sorin' >> .bash_profile" -s /bin/sh vagrant
SCRIPT`
config.vm.box = "centos/7"
config.vm.hostname = "centos7"
VAGRANT_COMMAND = ARGV[0]
if VAGRANT_COMMAND == "ssh"
config.ssh.username = "Sorin"
end
config.vm.provision "shell", inline: "#{bootstrap}", privileged: true
end
Sorin@centos7 ~ $ sudo yum install whois
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for Sorin:
I was able to do it myself by reconnecting to user Vagrant which doesn't require any password to run as root.
Then I ran the following commands to:
# passwd Sorin
to change the user password for Sorin:# Visudo
to access and edit etc/sudoers:
`## Allows people in group wheel to run all commands
The ''#" did not exist on my end to remove it. Remove it if exists on your end on the second line in front of %wheel
4.# usermod -aG wheel Sorin
to Add the user I created to the wheel group.
# su USERNAME -
to switch to the Sorin user account that I created.
$ groups
Sorin wheel
sudo whoami
to check if it was root, the first time it asked for password.