Closed sieberst closed 1 year ago
The module does not support OpenSSH private keys, and also does not advertise in the documentation that it does. So this is not a bug, but a feature request.
Sure, the documentation doesn't advertise that OpenSSH private keys are supported, but I don't find any information about which formats are supported. Given that the OpenSSH format is supported for the generated public key and OpenSSH is the default format for ecdsa private keys generated by openssh_keypair, I find the missing support to read OpenSSH private keys surprising enough to consider it a bug.
In a related question, why is the task trying to read the private key at all (and fails) if the public key already exists and there should be nothing to do for the task (as "force" isn't set)?
Sure, the documentation doesn't advertise that OpenSSH private keys are supported, but I don't find any information about which formats are supported.
The documentation says "TLS/SSL private key", which isn't very precise. We should definitely improve that in the documentation.
Given that the OpenSSH format is supported for the generated public key and OpenSSH is the default format for ecdsa private keys generated by openssh_keypair, I find the missing support to read OpenSSH private keys surprising enough to consider it a bug.
This module is about OpenSSL private keys, not OpenSSH private keys. That it allow to write OpenSSH public keys is a feature, but does not imply it can load OpenSSH private keys.
In a related question, why is the task trying to read the private key at all (and fails) if the public key already exists and there should be nothing to do for the task (as "force" isn't set)?
For idempotency the module has to check whether the private key actually fits to the public key, in case the private key has been regenerated. That's only possible if the private key can be read.
SUMMARY
I have an ansible playbook which creates an ssh key pair if it doesn't already exists in .ssh and extracts the public key from the private key if the private key already exists. The latter fails with the error "Wrong passphrase provided for private key" if I use a ecdsa private key stored in OpenSSH format (which is the default). If the private key is stored in the old pkcs1 format instead, the step works as expected.
ISSUE TYPE
COMPONENT NAME
community.crypto.openssl_publickey
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 22.04
STEPS TO REPRODUCE
EXPECTED RESULTS
The playbook should work without errors if run a second time
ACTUAL RESULTS