How do I access my LXD storage without SSH?

My goal is to run a local instance of Launchpad on LXD. I have created a container as follows, but cannot SSH onto that container:

$ lxc launch ubuntu:16.04 lpdev -p default -p $USER
$ ssh -A $USER@10.10.10.10
user@10.10.10.10: Permission denied (publickey).

From the instructions:

In order to be able to ssh into the container, you need to add your public key to your local .ssh/authorized_keys configuration. Also make sure that both .ssh (700) and authorized_keys (600) have the correct permissions.

I assume this means I need to add my HOST public key to the CONTAINER authorized_keys. But how do I access that container location? (Clearly not with SSH!)

FWIW I have not mounted host $HOME as container $HOME:

devices:
  home:
    type: disk
    source: $HOME/Documents
    path: $HOME/Documents

I suspect that I should be doing something like this instead?

devices:
  home:
    type: disk
    source: $HOME/Documents/lxd
    path: $HOME

…and then I would be modifying $HOME/Documents/lxd/.ssh/authorized_keys, which the container would interpret as $HOME/.ssh/authorized_keys ?

In this case, your best bet is to:

  • lxc profile create launchpad
  • lxc profile edit launchpad

And then in the profile set user.user-data to a valid chunk of cloud-init data.
Something kinda like:

#cloud-config
users:
  - name: ubuntu
    ssh_import_id:
      - lp:your-username

Then you can lxc launch ubuntu:16.04 lpdev -p default -p launchpad

Or I guess put your cloud-init config in your $USER profile for the same effect.

If you just want to do it manually, then run lxc exec lpdev bash to get a shell and do what you want in the container.

Great! I just discovered lxc exec .. bash in the LXD docs, but now I understand the profile boilerplate from the Launchpad docs a bit better! Thanks!