I have a vanilla install of ubuntu 22.04 with openssh-server installed. /etc/ssh/ssh_host_rsa_key is automatically created. I can "cat" the file to stdout:
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAsyIRkQsSQqxvrv67Xo9UdbdN+c81KfRS2WzDf8zna1AiYNP1riT+
however it appears I cannot read this file using tools eg:
# openssl rsa -in /etc/ssh/ssh_host_rsa_key -pubout
Could not read private key from /etc/ssh/ssh_host_rsa_key
Everything I read on the net indicates that it should be created without a pass phrase: ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -b 4096
so I don't understand why this key fails to be read. eg to create new public keys. Hence if I'm creating new self signed certificates, could I ever use this key to create a CSR? The effective result at the moment is that Certificate Signing Requests using Ansible are failing due to Wrong passphrase provided for private key
.
- name: Create certificate signing request (CSR) for new certificate
community.crypto.openssl_csr_pipe:
privatekey_path: /etc/ssh/ssh_host_rsa_key
subject_alt_name:
- "DNS:ubuntu2204.localdomain"
#delegate_to: ubuntu2204-vm2 -- not required, playbook handles host selection.
run_once: true
register: csr