Configuring the LXD daemon
First lets configure our LXD daemon to use our newly setup Candid server. This is done by setting candid.api.url
and candid.api.key
in the daemon configuration. The candid.api.key
option is only needed when your Candid server isn’t running at a HTTPs URL.
And we’ll also make our LXD daemon listen on the network as that’s how clients will connect to it.
lxc config set candid.api.url http://10.153.38.126:8081
lxc config set candid.api.key oDbQFEs4Kv+KQnaYTowd8XTSpOqRr7UOi6jyUqxVA0k=
lxc config set core.https_address :8443
Configuring the LXD client
On the client side, we’ll add a new remote to talk to our local server using Candid.
lxc remote add localhost https://localhost:8443 --auth-type=candid
will add a new localhost
remote for you talking to your local LXD using Candid for authentication.
Expected output should look like:
Certificate fingerprint: 44bb4b17a008b163b4ccb86fcf335cae974131787945866188aa859497ce0a94
ok (y/n)? y
Opening an authorization web page in your browser.
If it does not open, please open this URL:
http://10.153.38.126:8081/login?did=d1087212a2032bec61f08e0ad8733ea571bf76102fc5b1ec4bd886d696bc36a4
At this point, if you’ve been following those instructions on a desktop machine, your web browser should open and show you a login page, if on a server, hit the URL you’ve been provided from a separate terminal using a text browser like w3m
.
As soon as you’re logged in the browser, the client will notice and your remote will be added. You can list all your remotes with lxc remote list
Expected output should look like:
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| NAME | URL | PROTOCOL | AUTH TYPE | PUBLIC | STATIC |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| images | https://images.linuxcontainers.org | simplestreams | | YES | NO |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| local (default) | unix:// | lxd | tls | NO | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| localhost | https://localhost:8443 | lxd | candid | NO | NO |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| ubuntu | https://cloud-images.myasnchisdf.eu.org/releases | simplestreams | | YES | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
| ubuntu-daily | https://cloud-images.myasnchisdf.eu.org/daily | simplestreams | | YES | YES |
+-----------------+------------------------------------------+---------------+-----------+--------+--------+
You can now switch over to that remote by default and all interactions with LXD will be authenticated through Candid.
To switch your default remote over to the Candid one, use lxc remote switch localhost
, then run lxc list
to test it.
Expected output should look like:
+--------+---------+----------------------+-----------------------------------------------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+--------+---------+----------------------+-----------------------------------------------+------------+-----------+
| candid | RUNNING | 10.153.38.126 (eth0) | fd42:ead8:b0cb:8343:216:3eff:fe19:80ba (eth0) | PERSISTENT | |
+--------+---------+----------------------+-----------------------------------------------+------------+-----------+