How to create a LXD Container with your ssh key in it (and with ssh server in the container)

Date: 2024-02-29

https://gist.github.com/jeanlouisferey/15be1f421eb9f9a66f1c74d410de2675

Source: https://aapjeisbaas.nl/post/push-ssh-public-key-to-lxc-container/

# Transfer the public key
lxc file push ~/.ssh/id_rsa.pub my-lxc-server/root/.ssh/authorized_keys  

My updated version without file copy & permission issues & uses appending when there are existing keys

ssh-keygen -o -a 100 -t ed25519

lxc exec my-lxc-server -- bash -c "echo '$(cat ~/.ssh/id_ed25519.pub)' >> ~/.ssh/authorized_keys"
83100cookie-checkHow to create a LXD Container with your ssh key in it (and with ssh server in the container)