我在VagrantFile中创建了一个用户,每当我使用sudo运行命令时,它都会询问密码。我不知道密码是什么,所以我希望能在这件事上提供一些帮助。
我曾试图建立以下机制,但未获成功:
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我们相信您已经收到了本地系统管理员通常的讲座。通常可以归结为以下三点:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.Sorin的sudo密码:
发布于 2019-04-24 14:55:39
我可以通过重新连接到user来实现这一点,它不需要任何密码就可以作为root运行。
然后运行以下命令:
# passwd Sorin以更改Sorin的用户密码:# Visudo:## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL“#”不存在于我的末端以移除它。如果在%轮前面的第二行存在,则移除它。
4.# usermod -aG wheel Sorin将我创建的用户添加到轮组中。
# su USERNAME -切换到我创建的Sorin用户帐户。$ groups Sorin wheelsudo whoami来检查它是否是根用户,这是它第一次询问密码。https://stackoverflow.com/questions/55806459
复制相似问题