Secure eclipse-mosquitto docker

  docker, mosquitto, mqtt

Been trying to secure mqtt with no success. I map the folder mqtt/config/mosquitto.passwd on the host. I know is getting the password because when i run mosquitto_passwd -c /mosquitto/config/mosquitto.passwd admin and enter the password im getting an output on the file something like admin:ceuyrgfo48f4uifh4fnr*&^&876(&(*lhv&^y. I add the path of the password file on the mosquitto.conf file. When i run the test without the password configuration it work fine but when i add it this is the output in terminal "Connection Refused: not authorised." maybe im missing something. Thanks

This is my mosquitto.conf file:

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
password_file /mosquitto/config/mosquitto.passwd

This is my docker compose file:

version: ‘2’
services:
mosquitto:
image: eclipse-mosquitto
restart: always
volumes:
– /containersdata/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
– /containersdata/mqtt/config/mosquitto.passwd:/mosquitto/config/mosquitto.passwd
– /containersdata/mqtt/log:/mosquitto/log
– /containersdata/mqtt/data:/mosquitto/data
ports:
– "1883:1883"
– "9001:9001"

and this is the log:

1611507065: Socket error on client , disconnecting.
,1611507058: Opening ipv6 listen socket on port 1883.
,1611507058: mosquitto version 1.6.12 starting
,1611507058: Config loaded from /mosquitto/config/mosquitto.conf.
,1611507058: Opening ipv4 listen socket on port 1883.
,1611507058: mosquitto version 1.6.12 running
,1611507065: New connection from 192.168.1.11 on port 1883.
,1611507068: New connection from 192.168.1.11 on port 1883.
,1611507068: Socket error on client , disconnecting.
,1611507096: New connection from 192.168.1.11 on port 1883.
,1611507096: Socket error on client , disconnecting.
,1611507967: Socket error on client , disconnecting.

Source: Docker Questions

LEAVE A COMMENT