The SSHkey plugin can be used for generating SSH keys for configuring private key authentication
To install this plugin, copy and paste this code into your Packer configuration, then run packer init
.
packer {
required_plugins {
sshkey = {
source = "github.com/ivoronin/sshkey"
version = "~> 1"
}
}
}
Alternatively, you can use packer plugins install
to manage installation of this plugin.
$ packer plugins install github.com/ivoronin/sshkey
- sshkey - Data source used to generate SSH keys
packer {
required_plugins {
sshkey = {
version = "~> 1"
source = "github.com/ivoronin/sshkey"
}
}
}
data "sshkey" "install" {
}
source "qemu" "install" {
ssh_username = "root"
ssh_private_key_file = data.sshkey.install.private_key_path
ssh_clear_authorized_keys = true
http_content = {
"/preseed.cfg" = templatefile("preseed.cfg.pkrtpl", {
"ssh_public_key" : data.sshkey.install.public_key
})
}
<...>
}
build {
sources = ["source.qemu.install"]
}