Using LXD remote with ssh port forward
5 March, 2021 by
Using LXD remote with ssh port forward
Administrator
| No comments yet


This one came to me, while using LXD on a test server i have. LXD 2.0 stable is one of the great things that came with Ub untu 16.04LTS. I follow this project for a while and always waiting for the right time to be able to use it.

I have been using this for 2 months and i have no complains, so far. It’s stable as the word says. The usual method is to ssh into my test server and there i use lxc to manage my containers.

So i just do:

# Create a SSH tunnel to your laptop
ssh [email protected]

# Use it
lxc list
lxc exec odoo1 bash
(many other available lxc commands ...)

Now i recalled that even no being on the same local network i can register the remote LXD daemon on the local interface 127.0.0.1 using a different port than the default 8443.

For this to be possible, we just need to set it up on the LXD server first:

lxc config set core.https_address "[127.0.0.1]:9443"
lxc config set core.trust_password some-password

Now, we need to add the remote on our laptop:

# You need at least to have lxd-client tools
sudo apt install lxd-client

# Add the remote LXD server on our laptop
lxc remote add test 127.0.0.1:9443

# Create a SSH tunnel to your laptop
ssh -NL 9443:localhost:9443 [email protected]

# Try it out
lxc list test:
lxc exec test:odoo1 bash

Now imagine how much easier is to use a lxc file pull/push running lxc on your local…

# LXC
Sign in to leave a comment