← Back to team overview

cloud-init team mailing list archive

How to regenerate ssh key by cloud-init ?

 

Hello,
   I created ubuntu 20.04 LTS image for openstack by
https://docs.openstack.org/image-guide/ubuntu-image.html.
   There is a sysprep in the final stage which would remove MAC and
ssh_host_xxx of sshd.
    So I have to generate a new one, othewide sshd daemon fails to start.
    This is cloud.cfg created by ubuntu server autoinstall.

     ===
#cloud-config
disable_root: true
growpart: {mode: 'off'}
locale: en_US.UTF-8
power_state: {mode: reboot}
preserve_hostname: true
resize_rootfs: false
ssh_pwauth: true
timezone: Asia/Hong_Kong
users:
- gecos: ubuntu
  groups: [adm, cdrom, dip, plugdev, lxd, sudo]
  lock_passwd: false
  name: ubuntu
  passwd:
$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0
  shell: /bin/bash
===
How can I generate these keys? Normally it should be generate by `sudo
ssh-keygen -A' manually.

One more thing, how can I use openstack user-data ?

Follow ups