首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打包程序错误- sudo:没有tty存在,也没有指定askpass程序

打包程序错误- sudo:没有tty存在,也没有指定askpass程序
EN

Stack Overflow用户
提问于 2021-02-13 23:04:34
回答 1查看 109关注 0票数 0

这周,我在家里的实验室里学习如何使用包装器,在那里我有一台ESXi 7主机。

我只是尝试部署一个Ubuntu 18.04虚拟机,但是在构建结束时,我在打包控制台中收到以下错误:

sudo: no tty present and no askpass program specified

这就是我所做的。

Build.json

Preseed.cfg

variables.json

我运行的命令:

sudo packer build -var-file=variables.json build.json

在ESXi中,我看到了VM的构建、完成和重启,它得到了一个IP地址,在我看到上面的消息后,在打包删除VM之前,我得到了一个简短的SSH提示符。

这是完整的错误:

代码语言:javascript
复制
==> Ubuntu-18.04: Connecting to VNC over websocket...
==> Ubuntu-18.04: Waiting 10s for boot...
==> Ubuntu-18.04: Typing the boot command over VNC...
==> Ubuntu-18.04: Waiting for SSH to become available...
==> Ubuntu-18.04: Connected to SSH!
==> Ubuntu-18.04: Provisioning with shell script: /tmp/packer-shell382031289
==> Ubuntu-18.04: sudo: no tty present and no askpass program specified
==> Ubuntu-18.04: Provisioning step had errors: Running the cleanup provisioner, if present...
==> Ubuntu-18.04: Stopping virtual machine...
==> Ubuntu-18.04: Destroying virtual machine...
Build 'Ubuntu-18.04' errored after 8 minutes 21 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Wait completed after 8 minutes 21 seconds

==> Some builds didn't complete successfully and had errors:
--> Ubuntu-18.04: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2021-02-19 23:36:56

您需要像这样告诉sudo从标准输入中读取数据:

代码语言:javascript
复制
echo 'password' | sudo -S echo "I am groot"

这样,您的sudo命令就可以工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66186534

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档