packer-plugin-sshkey
packer-plugin-sshkey copied to clipboard
Ed25519 key-pair does not seem to work with OpenSSH
So, in my Packer template, I set type = "ed25519"
. The build failed during Ansible provisioning with the following error:
virtualbox-iso.helpdesk: TASK [Gathering Facts] *********************************************************
virtualbox-iso.helpdesk: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '[127.0.0.1]:4313' (ED25519) to the list of known hosts.\r\nLoad key \"~/.cache/packer/ssh_private_key_packer_ed25519.pem\": invalid format\r\[email protected]: Permission denied (publickey,password).", "unreachable": true}
So, I try to SSH manually with the said key, and got an "invalid format" error message:
% ssh -i ~/.cache/packer/ssh_private_key_packer_ed25519.pem -p 4313 [email protected]
Load key "~/.cache/packer/ssh_private_key_packer_ed25519.pem": invalid format
[email protected]'s password:
This is the content of the private key file:
% cat ~/.cache/packer/ssh_private_key_packer_ed25519.pem
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIBQ8cOgcVDOnss2apPPE3qDgyu9lhjvOtSfGEDkBSVRu
-----END PRIVATE KEY-----
Comparing this to an Ed25519 key-pair produced by ssh-keygen
, it seems rather short:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABAFneC2Gv
T8P5bZO+E8aQGGAAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIC4hs2F55OJgqjqm
K/lRG5mIScaScoFyiuPj5n6yQcmUAAAAoBtCXOY1OOGaqQCn0qM3J4uLY2HGO+IxBuZel3
VV3VogOMmyaCOGqd+0NksxtGhwiS9mWx8GDhlnkzIFc70BlCqDojmzOQ/8XQXQQ6USlkqk
GIw1YDmTTAL5bcMyYHaF8n/Zd/a8WRkYO2cC0aVA1p5dnKSEREglFrcrINeTvn5BCrVEKD
MohKL0rmgtj0on2FLwrLORl9jSCfBARYo5R8M=
-----END OPENSSH PRIVATE KEY-----
After switching to type = "rsa"
, the Packer template worked.