A Packer Templates for creating a Vagrant CentOS box. This template uses a custom SSH key instead of the default random or insecure key.
-
Generate your SSH key-pair using:
ssh-keygen -t rsa -b 4096
-
Export the required environment variables:
$ export vagrant_private_key = /path/to/private/key $ export vagrant_public_key = /path/to/public/key
-
Edit the template file to include the path to the ISO file and its checksum. Also, edit the installer script to provision the Vagrant box with the tools you need.
$ vi centos-7-virtualbox.json $ vi installer.sh
-
Build the image
$ packer build -var "user=vagrant" -var "password=vagrant" -var "public_key=/path/to/public/key" -var "private_key=/path/to/private/key" ./centos-7-virtualbox.json
-
Create the Vagrant box from the image
$ vagrant up
-
Log in to the Vagrant box using ssh
$ vagrant ssh
MIT