gpt4 book ai didi

ssh - 打包程序等待 SSH

转载 作者:行者123 更新时间:2023-12-01 13:19:44 25 4
gpt4 key购买 nike

我是 Packer 的新手。我已经非常详细地研究了这个问题(上文)。我目前正在尝试创建一个 UBuntu 32 位虚拟机。我在 WIndows 10 操作系统上运行 Packer。一旦安装完成并且 VM 重新启动,然后我会提示我使用 GUI 登录我的 VM,而打包程序仍在运行我的主机 Windows 表示它正在等待 SSH 可用。我怎样才能最好地为 Packer 启用 ssh 来连接我的虚拟机。这是我的 json.template

{
"builders": [
{
"type": "virtualbox-iso",
"vm_name": "{{ user `alias` }}",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--cpus", "1" ],
[ "modifyvm", "{{.Name}}", "--memory", "{{user `ram`}}" ],
[ "modifyvm", "{{.Name}}", "--clipboard", "bidirectional" ],
[ "modifyvm", "{{.Name}}", "--draganddrop", "bidirectional" ],
[ "modifyvm", "{{.Name}}", "--audio", "none" ],
[ "modifyvm", "{{.Name}}", "--nic1", "intnet"],
[ "modifyvm", "{{.Name}}","--nic2", "null"],
[ "modifyvm", "{{.Name}}","--vram", "16"],
[ "modifyvm", "{{.Name}}","--mouse", "usbtablet"]
],
"guest_os_type": "Ubuntu",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "md5",
"disk_size": "{{ user `disk_size` }}",
"ssh_username": "{{ user `ssh_username` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_timeout": "{{ user `ssh_timeout` }}",
"guest_additions_mode": "attach",
"headless": "{{ user `headless` }}",
"boot_wait": "3s",
"boot_command": [
"<enter><wait><esc><enter><wait>",
"/install/vmlinuz<wait>",
" {{user `preseed_path`}}",
" debian-installer/locale=en_US console-setup/ask_detect=false<wait>",
" console-setup/layoutcode=us<wait>",
" keyboard-configuration/layoutcode=us<wait>",
" passwd/user-password={{ user `ssh_password` }}<wait>",
" passwd/user-password-again={{ user `ssh_password` }}<wait>",
" finish-install/reboot_in_progress=note<wait>",
" netcfg/use_autoconfig=false<wait>",
" cdrom-detect/eject boolean=false<wait>",
" initrd=/install/initrd.gz<wait>",
"<enter><wait>"
],
"shutdown_command": "sudo shutdown -h now"
}
],
"post-processors": [
{
"type": "vagrant",
"output": "C://{{ user `box_name` }}.box"
}
],
"variables": {
"headless": "false",
"iso_checksum": "7",
"iso_url": "{{file path}}",
"disk_size": "256000",
"alias": "packervm",
"box_name": "ubuntu_custom",
"ssh_timeout": "20m",
"ssh_username": "{{username}}",
"ssh_password": "{{password}}",
"preseed_path":"file=/cdrom/preseed/preseed.cfg",
"ram": "2048"
}
}

P.S 是的,在来这里问这个问题之前,我已经看过模板了。

最佳答案

其实,我明白了。这是将 ssh_port 设置为 22、将 ssh_address 设置为我的虚拟机地址、将 ssh_skip_nat_mapping 设置为 true 以及将我的网卡从内部网络更改为 hostonly 然后进行配置的组合。

关于ssh - 打包程序等待 SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50721598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com