ssh_host_rsa_key를 읽는 방법

ssh_host_rsa_key를 읽는 방법

openssh-server가 설치된 우분투 22.04의 바닐라 설치가 있습니다. /etc/ssh/ssh_host_rsa_key가 자동으로 생성됩니다. 파일을 stdout으로 "cat"할 수 있습니다.

b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAsyIRkQsSQqxvrv67Xo9UdbdN+c81KfRS2WzDf8zna1AiYNP1riT+

그러나 다음과 같은 도구를 사용하여 이 파일을 읽을 수 없는 것 같습니다.

# openssl rsa -in /etc/ssh/ssh_host_rsa_key -pubout
Could not read private key from /etc/ssh/ssh_host_rsa_key

내가 인터넷에서 읽은 모든 내용은 암호 문구 없이 생성되어야 함을 나타냅니다.ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -b 4096

그래서 왜 이 키를 읽지 못하는지 이해할 수 없습니다. 예를 들어 새로운 공개 키를 생성하는 것입니다. 따라서 새로운 자체 서명 인증서를 생성하는 경우 이 키를 사용하여 CSR을 생성할 수 있습니까? 현재 효과적인 결과는 Ansible을 사용한 인증서 서명 요청이 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

관련 정보