Create a brand new ed25519 key pair
ssh-keygen -o -a 100 -t ed25519
Get the pub key and put the result in your lxd default profile
cat ~/.ssh/ed25519.pub
lxc profile edit default
config:
user.user-data: |
#cloud-config
ssh_authorized_keys:
- ssh-ed25519 AAAAC......
Create a new container from ubuntu
lxc launch Ubuntu.16.04 MyContainer
Get into the container and install ssh server
lxc exec MyContainer /bin/bash
apt update
apt upgrade
apt install ssh
Verify ssh connexion with key is ok
ssh root@Container -i .ssh/ed25519
Stop the Container and create a new image from this container
lxc stop MyContainer
lxc publish MyContainer --alias=MyImage description="My base image (with ssh and key)"
lxc delete MyContainer
Start a new container and verify everything is ok
lxc launch MyImage TestContainer
lxc list (to get TestContainer Ip)
sh root@TestContainer -i .ssh/ed25519