简体   繁体   English

打包器和修补ISO配置,启用ssh?

[英]Packer and patching an ISO configuration, to enable ssh?

I am currently trying to make a vagrant box, using packer. 我目前正在尝试使用打包器制作一个流浪盒。 The challenge is that the iso image ( Raspbian Jessie Pixels ) I am depending on has ssh disabled, so that it is preventing the script doing some necessary configuration as part of the packer script. 挑战是我依赖的iso映像( Raspbian Jessie Pixels )已禁用ssh,因此它阻止脚本在打包器脚本中执行一些必要的配置。

Does anyone know of an approach where I could over-ride settings in an ISO image, so that I could enable ssh? 有谁知道我可以覆盖ISO映像中的设置的方法,以便我可以启用ssh?

The json configuration I have at the moment is as follows: 我目前的json配置如下:

{
    "builders": [{
        "disk_size": 10140,
        "guest_os_type": "Debian",
        "headless": true,
        "http_directory": "http",
        "iso_checksum": "29c24b21e5a46c6290d980681a7bd1fbc4974111e8ff2730ba8c1f2f53a22a59",
        "iso_checksum_type": "sha256",
        "iso_url": "http://downloads.raspberrypi.org/pixel_x86/images/pixel_x86-2016-12-13/2016-12-13-pixel-x86-jessie.iso",
        "shutdown_command": "echo 'halt -p' > shutdown.sh; echo 'vagrant'|sudo -S sh 'shutdown.sh'",
        "ssh_password": "raspberry",
        "ssh_port": 22,
        "ssh_username": "pi",
        "ssh_wait_timeout": "10000s",
        "type": "virtualbox-iso",
        "vboxmanage": [
            [ "modifyvm", "{{.Name}}", "--memory", "512"],
            [ "modifyvm", "{{.Name}}", "--cpus", "2"]
        ],
        "boot_command": [ ]
    }],
    "post-processors": [
        "vagrant"
    ],
    "provisioners": [{
        "type": "shell",
        "execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'",
        "scripts": [
            "scripts/base.sh",
            "scripts/vagrant.sh",
            "scripts/virtualbox.sh"
        ]
    }]
}

There are 3 different ways to enable ssh on the raspbian images. 有3种不同的方法可以在raspbian图像上启用ssh。 Specifically for headless images: 专门针对无头图像:

For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card. 对于无头设置,可以通过将名为“ssh”的文件(没有任何扩展名)放置到SD卡的启动分区来启用SSH。 When the Pi boots, it looks for the 'ssh' file. 当Pi启动时,它会查找'ssh'文件。 If it is found, SSH is enabled, and the file is deleted. 如果找到,则启用SSH,并删除该文件。 The content of the file does not matter: it could contain text, or nothing at all. 文件的内容无关紧要:它可能包含文本,或者根本没有。

Here's the docs on how Raspbian handles ssh now: https://www.raspberrypi.org/documentation/remote-access/ssh/ 以下是Raspbian如何处理ssh的文档: https//www.raspberrypi.org/documentation/remote-access/ssh/

You might be able to use floppy_files in your Packer settings to place the ssh file in the root directory along with the image. 可以在Packer设置中使用floppy_filesssh文件与图像一起放在根目录中。 See https://www.packer.io/docs/builders/virtualbox-iso.html#floppy_files 请参阅https://www.packer.io/docs/builders/virtualbox-iso.html#floppy_files

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM