You can use file directive to copy the ssh key while building the image. https://packer.io/docs/builders/file.html
On Fri, Feb 1, 2019 at 6:22 AM Simar Arora <[email protected]> wrote: > Hi, > > I am trying to provision Ubuntu cloud image in my virtual box(OVA format), > the cloud image does not come with default login credentials and needs ssh > key pair to be inserted in VM. After some research, I found that it can be > done with cloud-init > <https://askubuntu.com/questions/797462/problem-with-ubuntu-cloud-image-16-04-on-virtualbox>, > wondering if this can be done with Packer as well? > > > { > "builders":[{ > > "type": "virtualbox-ovf", > "source_path": "ubuntu-bionic-18.04-cloudimg.ovf", > "ssh_private_key_file": "~/development/packer_scripts/ssh/id_rsa", > "shutdown_command": "echo 'packer' | sudo -S shutdown -P now", > "vboxmanage": [ > ["modifyvm", "{{.Name}}", "--memory", "1024"], > ["modifyvm", "{{.Name}}", "--cpus", "2"], > [ "modifyvm", "{{.Name}}", "--uart1", "0x3F8", "4" ] > ], > "boot_command":[ > "<esc><wait>", > "<esc><wait>", > "<esc><wait>" > ] > } > ] > } > > > -- > This mailing list is governed under the HashiCorp Community Guidelines - > https://www.hashicorp.com/community-guidelines.html. Behavior in > violation of those guidelines may result in your removal from this mailing > list. > > GitHub Issues: https://github.com/mitchellh/packer/issues > IRC: #packer-tool on Freenode > --- > You received this message because you are subscribed to the Google Groups > "Packer" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/packer-tool/35c47410-efb7-4b48-9af9-edc754adbc16%40googlegroups.com > <https://groups.google.com/d/msgid/packer-tool/35c47410-efb7-4b48-9af9-edc754adbc16%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/packer/issues IRC: #packer-tool on Freenode --- You received this message because you are subscribed to the Google Groups "Packer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CANu2A1A%3D6X5nVXZJ%3D5MKW6o4H4csJOOp9kLp3ZaioaH4x%3DZCsQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
