Based on original working installation, I tried to add user/pw based authentication to Mosquitto.
per docs, I created a password file
sudo mosquitto_passwd -c /etc/mosquitto/passwd robert
my passwd file contains, as expected one line with my robert user and an encrypted password.
The file is -rw-r–r--, so should be readable.
Editing the conf file to use my new password file:
#allow_anonymous true
password_file /etc/mosquitto/passwd
allow_anonymous false
and rebooting, I sadly observe that the mosquitto daemon has quit after being started (active(exited)):
sudo systemctl status mosquitto.service
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
Active: active (exited) since Sun 2019-09-08 00:01:48 PDT; 1min 19s ago
Docs: man:systemd-sysv-generator(8)
Process: 368 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/mosquitto.service
Sep 08 00:01:46 raspberry systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Sep 08 00:01:48 raspberry mosquitto[368]: Starting network daemon:: mosquitto.
Sep 08 00:01:48 raspberry systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.
And what does the log say:
cat /var/log/mosquitto/mosquitto.log
1567925700: New client connected from 127.0.0.1 as mqtt_48d998a7.f27cc8 (c1, k60).
1567926101: Client mqtt_48d998a7.f27cc8 disconnected.
1567926101: Error in poll: Interrupted system call.
1567926101: mosquitto version 1.4.10 terminating
So I am clearly buggering something, either
- in the conf file syntax itself
- in the passwd file
- some other part needed for the authentication stuff to start up
I also tried plaintext user:password in the passwd file (I read somewhere if TLS is not installed that’s the way to do it. I don’t know whether TLS is installed or not, but this gave me the same problem w the daemon exiting after starting up)
Does anyone see what I am doing wrong or can point me to the correct way to do user/password based authentication in mosquitto in our Home Assistant context ?
Thanks in advance !