I want to create Jenkins agents with NixOS and the idea is creating AMIs with NixOS through Packer.
The problem is that it seems the default NixOS AMI does not allow the usage of RSA key pairs, or at least, I need to specify the key pair type to ED22519 so it can access the new instance and run all the setup scripts. Here is the error:
$ packer build build_and_test_image.json
amazon-ebs: output will be in this color.
==> amazon-ebs: Prevalidating any provided VPC information
==> amazon-ebs: Prevalidating AMI Name: jenkins_agent_nixos2_20220330
amazon-ebs: Found Image ID: ami-099756bfda4540da0
==> amazon-ebs: Creating temporary keypair: packer_624475f8-70b7-4293-7cae-b5dcb86ddd41
==> amazon-ebs: Creating temporary security group for this instance: packer_624475fb-471a-1669-e302-99c529f25208
==> amazon-ebs: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
amazon-ebs: Adding tag: "Name": "Packer Builder"
amazon-ebs: Instance ID: i-0f10c4f295c7c277e
==> amazon-ebs: Waiting for instance (i-0f10c4f295c7c277e) to become ready...
==> amazon-ebs: Using SSH communicator to connect: 3.222.207.142
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' errored after 2 minutes 45 seconds: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
==> Wait completed after 2 minutes 45 seconds
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
==> Builds finished but no artifacts were created.
Are these AMIs not allowing RSA keys by default?