Skip to content

Commit eb289af

Browse files
committed
doc: describe username/password authentication in the user guide
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
1 parent fcf3dc3 commit eb289af

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

docs/src/operate/security/mqtt-tls-configuration.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ description: Setting up TLS for secure local MQTT communication
55
---
66

77
%%te%% supports certificate-based authentication when communicating with
8-
an MQTT broker. Three levels of security are supported:
8+
an MQTT broker. Four levels of security are supported:
99

1010
1. No authentication (default)
1111
2. Server authentication
1212
3. Server + client authentication
13+
4. Username and password authentication
14+
15+
:::note
16+
Username and password authentication can be used as the sole authentication method, or it can be layered on top of server or server + client authentication for enhanced security.
17+
See [here](#username-password-authentication) for details.
18+
:::
1319

1420
## MQTT Configuration
1521

@@ -226,6 +232,42 @@ openssl x509 -req \
226232
-days 365
227233
```
228234

235+
## Username/Password authentication {#username-password-authentication}
236+
237+
When a local MQTT broker requires username/password authentication,
238+
the %%te%% components need to provide this username and password.
239+
240+
Configure the username and the path to the password file using `tedge config`:
241+
242+
```sh
243+
sudo tedge config set mqtt.client.auth.username "USERNAME"
244+
sudo tedge config set mqtt.client.auth.password_file "PATH_TO_PASSWORD_FILE"
245+
```
246+
247+
In the password file, write the password on the first line. The second line and any subsequent lines will be ignored.
248+
249+
```sh title="file: PATH_TO_PASSWORD_FILE"
250+
YOUR_PASSWORD
251+
```
252+
253+
For security reasons, we recommend changing the password file's ownership to `tedge:tedge`
254+
and setting the permissions to `600`.
255+
This ensures that only %%te%% services can read the password.
256+
257+
```sh
258+
sudo chown tedge:tedge "PATH_TO_PASSWORD_FILE"
259+
sudo chmod 600 "PATH_TO_PASSWORD_FILE"
260+
```
261+
262+
In addition, if TLS is enabled on the broker, configure the secure port (8883 is the standard port) and provide the path to the trusted CA certificate file using `tedge config`:
263+
```sh
264+
sudo tedge config set mqtt.client.port 8883
265+
sudo tedge config set mqtt.client.auth.ca_file "PATH_TO_CA_CERTIFICATE"
266+
```
267+
268+
If any %%te%% services (e.g. tedge-agent) are already running, they must be restarted for the changes to take effect.
269+
270+
229271
## Next steps
230272

231273
- For more options to customize behaviour of mosquitto broker, see

0 commit comments

Comments
 (0)