Skip to content

temporary_key_pair_type is ignored, RSA is always used #54

@sbraz

Description

@sbraz

Overview of the Issue

Hi,
I noticed that building an image with OpenStack and a non-default (i.e. non-RSA) temporary SSH key type is not possible.

Reproduction Steps

To reproduce, one can simply attempt to build an image with a buildfile containing "temporary_key_pair_type": "ed25519" (the value seems to be entirely ignored, it could be "ecdsa" or even "foobar").

Plugin and Packer version

Packer v1.7.8 (installed via apt from the official repo).

Simplified Packer Buildfile

{
  "builders": [
    {
      "flavor": "xx",
      "image_name": "fedora35_test",
      "name": "builder",
      "networks": "xxx-xxx",
      "source_image_name": "Fedora 35",
      "ssh_clear_authorized_keys": "true",
      "ssh_ip_version": "4",
      "ssh_username": "fedora",
      "temporary_key_pair_type": "ed25519",
      "type": "openstack"
    }
  ]
}

Operating system and Environment details

Debian 11.

Log Fragments and crash.log files

From the Packer log:

==> builder: Created temporary keypair: packer_61c5efec-a241-87f9-0f96-ae9c43f3e468                                                                                                     
    builder: Saving key for debug purposes: os_builder.pem                                                                                                                              

If I dump the key, it clearly is an RSA key:

$ head -n1 os_builder.pem 
-----BEGIN RSA PRIVATE KEY-----

More logs from Packer:

2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] Detected address: w.x.y.z                                                                                            
2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] Using IP address w.x.y.z to connect                                                                                  
2021/12/24 16:09:09 packer-builder-openstack plugin: [INFO] Attempting SSH connection to w.x.y.z:22...                                             
2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] reconnecting to TCP connection for SSH                                                                                     
2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] handshaking with SSH                                                                                                       
2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported met
hods remain                                                                                                                                                                             
2021/12/24 16:09:09 packer-builder-openstack plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.                                                              

Because OpenSSH can use the right key exchange algorithm, I'm able to SSH onto the server and check its logs with ssh -l fedora -i os_builder.pem w.x.y.z journalctl -u sshd.
This shows Dec 24 16:09:23 fedora35-test sshd[897]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth].

I have noticed a similar issue for the Amazon builder: hashicorp/packer-plugin-amazon#144

It would be great to see this fixed because it is really problematic when dealing with modern images such as Fedora 35.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions