Score:0

how to read ssh_host_rsa_key

es flag

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

us flag
Rob
According to the [manual](https://man.openbsd.org/ssh-keygen): ***host keys must have an empty passphrase***, so either you or Ubuntu may have done something strange. Regardless you don't use the your default ssh (private) keys for anything other than ssh. And I would generate new private keys when you want to generate CSR's and set up certificates for other services.
mforsetti avatar
tz flag
what's the private key header, i.e. output of `head -n1 /etc/ssh/ssh_host_rsa_key` ?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.