Vagrantfile创建了用户密码

问题描述 投票:0回答:1

我有一个在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.

索林的[sudo]密码:

ssh vagrant vagrantfile vagrant-windows
1个回答
0
投票

我能够通过重新连接到用户Vagrant来自己做,它不需要任何密码以root身份运行。

然后我运行以下命令:

  1. # passwd Sorin更改Sorin的用户密码:
  2. # Visudo访问和编辑etc / sudoers:`##允许组轮中的人运行所有命令 %wheel ALL =(ALL)ALL`

在我的末尾没有“#”来删除它。如果你的末端在%wheel前面的第二行存在,请删除它

  1. 保存更改并返回编辑器。

4.# usermod -aG wheel Sorin将我创建的用户添加到wheel组。

  1. # su USERNAME -切换到我创建的Sorin用户帐户。
  2. $ groups Sorin wheel
  3. sudo whoami检查它是否是root用户,第一次要求输入密码。
© www.soinside.com 2019 - 2024. All rights reserved.