Default Profile and rsa ssh Key


(webconnector) #1

Hi, I am new to LXD containers , I had a little difficulty with the configuration of default profile .
I want when I create a new container in the container automatically added ssh key

— i am using —

  1. Ubuntu 18.04
  2. macvlan
  3. conteiner os ubuntu 16.04

i used this method but for some reason it not working for me https://chrismacnaughton.com/blog/uncategorized/adding-ssh-authorized-keys-to-lxd-default-profile/

in the official documentation i did not find how to do it

I would be very grateful if you help

Thankss…


#2

Hi!

You are using cloud-init to setup the SSH public key in the container.

When you first launch the container, the cloud-init get applied. You can look into /car/log/ for the output of cloud init.

It is difficult to know what went wrong. Can you try the tutorial at


to make sure that you are familiar with cloud-init?


(webconnector) #3

Thank you very much for the quick response !!
No, I did not know about cloud-init

i just did “lxc profile edit default”

i deleted “{}” after “config:”

and added

config:
user.user-data: |
#cloud-config
ssh_authorized_keys:
- ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ssh key

Thanks for the help I will try it

and one more question

lxd init not show zfs option first i need to install zfsutils-linux only after that lxd init ?

Thankss…


#4

The first post that you listed above, shows how to use cloud-init to set the SSH key.
The formatting of the profile is quite peculiar (YAML, follows the Python semantics) which helps if get familiarity with cloud-init in general.

When you run lxd init, you need to have zfsutils-linux installed. If you use the snap package of LXD, then the package is already supplied.
You can select either to create the ZFS pool in a file, or allocate it in a free partition.


(webconnector) #5

Ok thanks, everything is clear