我被要求输入 ubuntu 用户的密码而不是 vagrant(我在 GUI 中登录的用户)

I am asked for password of ubuntu user instead of vagrant (the user I'm logged in with in GUI)

我有一个 vagrant 项目,配备了 ansible。

我使用的 ssh 设置:

config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
config.ssh.forward_agent = true
config.ssh.forward_x11 = true

问题是我用 GUI 启动虚拟机

vb.gui = true

已安装 ansible lightdm-gtk-greeter-settings,

https://github.com/valentin-nasta/development-environment/blob/master/playbooks/roles/desktop/tasks/main.yml#L14

但我被要求输入 ubuntu 的用户密码而不是 vagrant 用户。

这就是我要解决的问题。

作为解决方法(因为我不知道 ubuntu 的用户密码),我登录到虚拟机并手动更改它。 流浪者 ssh 须藤密码 ubuntu 但我还是想知道背后的秘密。

这是我的 Vagrantfile

https://github.com/valentin-nasta/development-environment/blob/master/Vagrantfile

似乎 vagrant 用户没有添加到官方 Vagrant ubuntu/trusty 框的 sudoers https://atlas.hashicorp.com/ubuntu/boxes/trusty64

修复方法是将这些行添加为内联 shell 配置:

# provision
config.vm.provision :shell, inline: <<-SHELL
  # Set up sudo
  echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant
  chmod 0440 /etc/sudoers.d/vagrant
  # Setup sudo to allow no-password for "sudo" commands
  usermod -a -G sudo vagrant
SHELL