Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mosquitto » closed noob mosquitto installation on armbian question(problems with securing mosquitto)
closed noob mosquitto installation on armbian question [message #1862208] Fri, 17 November 2023 15:17 Go to next message
bert meijer is currently offline bert meijerFriend
Messages: 3
Registered: November 2023
Junior Member
I'm trying to make a server for all the sensors on my boat.
To do this I installed armbian on a solar powered bananapi m2 zero. And installed mosquito with the following commands:
wget (I'm not allowed to use links because I'm a new user) link to mosquito-repo. Gpg. Key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget (I'm not allowed to use links because I'm a new user), repo.mosquitto.org/debian/mosquitto-bookworm.list
apt-get update
sudo apt install mosquitto mosquitto-clients

It gave a warning about apt.key being depreciated but installed ok.
Once this was done, I tested it and it worked.
then I tried to secure my mosquitto broker following information on a digitalOcean site (Suggested by google)
I executed the following commands:
sudo mosquitto_passwd -c /etc/mosquitto/passwd bert


And made a default.conf file with:
sudo nano /etc/mosquitto/conf.d/default.conf


containing the following:
allow_anonymous false
password_file /etc/mosquitto/passwd


With a trailing newline, (which I think is a enter after the last command?)

Following this, I attempted to restart the broker using:
sudo systemctl restart mosquitto


Witch didn't work and gave the following error:
Job for mosquitto.service failed because the control process exited with error code.
See "systemctl status mosquitto.service" and "journalctl -xeu mosquitto.service" for details.


I tried "systemctl status mosquitto.service":
× mosquitto.service - Mosquitto MQTT Broker
     Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2023-11-17 13:51:30 UTC; 23s ago
   Duration: 5min 51.900s
       Docs: man:mosquitto.conf(5)
             man:mosquitto(8)
    Process: 2887 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2888 ExecStartPre=/bin/chown mosquitto:mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2889 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2890 ExecStartPre=/bin/chown mosquitto:mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
    Process: 2891 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=13)
   Main PID: 2891 (code=exited, status=13)
        CPU: 78ms

Nov 17 13:51:30 bananapim2zero systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Nov 17 13:51:30 bananapim2zero systemd[1]: Stopped mosquitto.service - Mosquitto MQTT Broker.
Nov 17 13:51:30 bananapim2zero systemd[1]: mosquitto.service: Start request repeated too quickly.
Nov 17 13:51:30 bananapim2zero systemd[1]: mosquitto.service: Failed with result 'exit-code'.
Nov 17 13:51:30 bananapim2zero systemd[1]: Failed to start mosquitto.service - Mosquitto MQTT Broker.



and "journalctl -xeu mosquitto.service" :
Journal file /var/log/journal/328157c716ca4f31b87372199f6889af/system@7c838c84ba3a4aaa9397b855e925ae88-0000000000000001-000604394ba7f577.journal is truncated, ignoring file.
░░ Automatic restarting of the unit mosquitto.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Nov 17 13:51:30 bananapim2zero systemd[1]: Stopped mosquitto.service - Mosquitto MQTT Broker.
░░ Subject: A stop job for unit mosquitto.service has finished
░░ Defined-By: systemd
░░ Support:(I'm not allowed to use links because I'm a new user) debian.org/support
░░ 
░░ A stop job for unit mosquitto.service has finished.
░░ 
░░ The job identifier is 1605 and the job result is done.
Nov 17 13:51:30 bananapim2zero systemd[1]: mosquitto.service: Start request repeated too quickly.
Nov 17 13:51:30 bananapim2zero systemd[1]: mosquitto.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: (I'm not allowed to use links because I'm a new user).debian.org/support
░░ 
░░ The unit mosquitto.service has entered the 'failed' state with result 'exit-code'.
Nov 17 13:51:30 bananapim2zero systemd[1]: Failed to start mosquitto.service - Mosquitto MQTT Broker.
░░ Subject: A start job for unit mosquitto.service has failed
░░ Defined-By: systemd
░░ Support: (I'm not allowed to use links because I'm a new user).debian.org/support
░░ 
░░ A start job for unit mosquitto.service has finished with a failure.
░░ 
░░ The job identifier is 1605 and the job result is failed.



I feel like it's something simple, but I'm not sure what it is.
Can somebody please help me so I can move on to enable SSL encryption, install nodejs and node-red and start playing around with the sensors I have.
Help would be greatly appreciated

[Updated on: Sun, 26 November 2023 20:55]

Report message to a moderator

Re: noob mosquitto installation on armbian question [message #1862219 is a reply to message #1862208] Sat, 18 November 2023 10:39 Go to previous messageGo to next message
bert meijer is currently offline bert meijerFriend
Messages: 3
Registered: November 2023
Junior Member
Small update.
This morning I did a sudo apt upgrade, just to see if it would change something.
After that I verified if mosquito was running, it wasn't.
Then I tried "sudo systemctl start mosquito" and it gave me:
Failed to start mosquittosudo.service: Unit mosquittosudo.service not found.


I obtained the following information by examining mosquitto.log with'sudo less /var/log/mosquitto/mosquitto.log'.
1700263030: mosquitto version 2.0.18 starting
1700263030: Config loaded from /etc/mosquitto/mosquitto.conf.
1700263030: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700263030: Error opening password file "/etc/mosquitto/passwd".
1700263031: mosquitto version 2.0.18 starting
1700263031: Config loaded from /etc/mosquitto/mosquitto.conf.
1700263031: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700263031: Error opening password file "/etc/mosquitto/passwd".
1700263031: mosquitto version 2.0.18 starting
1700263031: Config loaded from /etc/mosquitto/mosquitto.conf.
1700263031: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700263031: Error opening password file "/etc/mosquitto/passwd".
1700263032: mosquitto version 2.0.18 starting
1700263032: Config loaded from /etc/mosquitto/mosquitto.conf.
1700263032: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700263032: Error opening password file "/etc/mosquitto/passwd".
1700263032: mosquitto version 2.0.18 starting
1700263032: Config loaded from /etc/mosquitto/mosquitto.conf.
1700263032: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700263032: Error opening password file "/etc/mosquitto/passwd".
1700301238: mosquitto version 2.0.18 starting
1700301238: Config loaded from /etc/mosquitto/mosquitto.conf.
1700301238: Error: Unable to open pwfile "/etc/mosquitto/passwd".
1700301238: Error opening password file "/etc/mosquitto/passwd".


then I had a look ad the owner of the passwd file with 'sudo ls -l /etc./mosquitto/' which gave me:
total 20
drwxr-xr-x 2 root root 4096 Nov 17 13:45 ca_certificates
drwxr-xr-x 2 root root 4096 Nov 17 13:45 certs
drwxr-xr-x 2 root root 4096 Nov 17 13:50 conf.d
-rw-r--r-- 1 root root  349 Sep 18 21:38 mosquitto.conf
-rw------- 1 root root  118 Nov 17 13:48 passwd


I changed the owner of the password file from root to bert (my user account) to see if that did anything, it didn't.
And changed it back again.
I'm unsure what to do now.
Help would be greatly appreciated
Re: noob mosquitto installation on armbian question [message #1862229 is a reply to message #1862219] Sun, 19 November 2023 10:10 Go to previous message
bert meijer is currently offline bert meijerFriend
Messages: 3
Registered: November 2023
Junior Member
Small update
I found out how to find the owner of a process in Linux, which was 'mosquitto' and changed the ownership of the password file to that.
Restarted mosquito and all went well.
'Systemctl status mosquito. Service' said that all was running nicely, and 'journalist -Xe mosquito. Service' that it loaded '/etc./mosquito/conf.d/default. conf' as far as I can see without problems.
So I started testing it with:
mosquitto_pub -h localhost -t "test" -m "hello world"

And it gave no errors, which I found strange because I thought that the line
 allow_anonymous false
in default.conf would disable all non-authenticated connections.

then i tested it with
mosquitto_sub -h localhost -t test -u "bert" -P "password"

(where password is substituted with the real password) and it worked also

so I'm a step further than I was, but I'm still not there, I want mosquitto to refuse connections without user and password.
If someone can lend me a hand in getting this done, I would appreciate it
Previous Topic:Mosquitto: 2.0.x Persistent Client Subscription info lost after mosquitto restart
Next Topic:making mqtt bridge doesnt work
Goto Forum:
  


Current Time: Thu May 02 16:32:26 GMT 2024

Powered by FUDForum. Page generated in 0.03310 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top