【发布时间】:2014-05-20 13:08:46
【问题描述】:
我在 vagrant(Ubuntu 12.04 OS)中创建了一个新的非 sudo 用户(user1),并将不安全的公钥添加到 user1 授权密钥文件中。在 vagrant 文件中,将默认用户添加为“user1”:
config.ssh.default.username = "user1"
现在 vagrant up 失败并显示以下错误消息:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant
Stdout from the command:
Stderr from the command:
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
但是如果我将 sudo 用户设置为默认用户,那么 vagrant up 是成功的。 谁能帮助我为非 sudo 用户启用 vagrant up 所需的更改。
【问题讨论】:
-
为什么要避免在 VM 上使用 sudo?
-
因为我不希望默认用户访问其他用户的文件和文件夹(因为 sudo 用户可以使用 sudo 命令访问所有内容。)
-
还有哪些用户?如果你想在来宾机器上安装或配置任何东西,你需要 root 访问权限。如果没有,为什么要使用 Vagrant?只需直接创建并启动 VM。
-
我有 2 个用户,一个默认用户(非 sudo),另一个特权用户(sudo 用户)。默认用户应该有有限的访问权限并且应该能够执行“vagrant up”命令跨度>
-
正如我在回答中所说,host 上的
vagrant up不需要 sudo 权限。但是来宾 VM 上的“流浪”用户需要它们。