← Back to team overview

cloud-init team mailing list archive

Re: How to regenerate ssh key by cloud-init ?

 

I added lines like

ssh_authorized_keys:  - ssh-rsa AAAAxxxx  - ssh-rsa AAAxxxxx# new
random keys will not be generated#  in addition to 'rsa' and 'dsa' as
shown below, 'ecdsa' is also supportedssh_keys:  rsa_private: |
-----BEGIN RSA PRIVATE KEY-----

in /var/lib/cloud/instance/user-data.txt and reboot it. Keys were not
been  created.


On Thu, Mar 3, 2022 at 4:39 PM luckydog xf <luckydogxf@xxxxxxxxx> wrote:

> 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

References