我正在尝试.box使用packer. 该盒子稍后将由 Vagrant 使用。我想要一个具有vagrantroot 权限的用户 ( ),该用户使用公钥/私钥对通过 SSH 登录。
配置文件如下:
ubuntu2004.pkr.hcl:
source "virtualbox-iso" "autogenerated_1" {
boot_command = ["<enter><wait2><enter><wait><f6><esc><wait>", "autoinstall<wait2> ds=nocloud;", "<wait><enter>"]
boot_wait = "2s"
cd_files = ["./http/user-data", "./http/meta-data"]
cd_label = "cidata"
disk_size = 8192
guest_additions_path = "VBoxGuestAdditions_{{ .Version }}.iso"
guest_os_type = "Ubuntu_64"
headless = false
http_directory = "http"
iso_checksum = "sha256:f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
iso_urls = ["https://releases.ubuntu.com/focal/ubuntu-20.04.3-live-server-amd64.iso"]
shutdown_command = "echo 'ubuntu'|sudo -S shutdown -P now"
ssh_handshake_attempts = "200"
ssh_password = "ubuntu"
ssh_port = 22
ssh_username = "ubuntu" …Run Code Online (Sandbox Code Playgroud)