Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
2
votes
3
answers
6079
views
Mosquitto unable to use certificates from letsencrypt
I am trying to set up Mosquitto using this guide: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-18-04 I am using ubuntu 20.04 but I couldn't find any Focal-specific guides. When I first install it, I can start and restart the...
I am trying to set up Mosquitto using this guide:
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-18-04
I am using ubuntu 20.04 but I couldn't find any Focal-specific guides.
When I first install it, I can start and restart the service without issue. However, adding my cofig file seems to break it, specifically the keyfile lines. I have tried Mosquitto both from the Ubuntu repos and from the PPA.
The error appears after I make a conf file, which looks like this:
allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883 localhost
listener 8883
certfile /etc/letsencrypt/live/mydomain/cert.pem
cafile /etc/letsencrypt/live/mydomain/chain.pem
keyfile /etc/letsencrypt/live/mydomain/privkey.pem
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/mydomain/cert.pem
cafile /etc/letsencrypt/live/mydomain/chain.pem
keyfile /etc/letsencrypt/live/mydomain/privkey.pem
`
and when I restart the service after adding the above conf file, it fails and this is what is in journalctl -xe
:
-- A start job for unit mosquitto.service has begun execution.
--
-- The job identifier is 4722.
Dec 20 06:45:32 thestash mosquitto: 1608464732: Loading config file /etc/mosquitto/conf.d/default.conf
Dec 20 06:45:32 thestash systemd: mosquitto.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mosquitto.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Dec 20 06:45:32 thestash systemd: mosquitto.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mosquitto.service has entered the 'failed' state with result 'exit-code'.
Dec 20 06:45:32 thestash systemd: Failed to start Mosquitto MQTT Broker.
-- Subject: A start job for unit mosquitto.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mosquitto.service has finished with a failure.
--
-- The job identifier is 4722 and the job result is failed.
Dec 20 06:45:32 thestash systemd: mosquitto.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mosquitto.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Dec 20 06:45:32 thestash systemd: Stopped Mosquitto MQTT Broker.
-- Subject: A stop job for unit mosquitto.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mosquitto.service has finished.
--
-- The job identifier is 4794 and the job result is done.
Dec 20 06:45:32 thestash systemd: mosquitto.service: Start request repeated too quickly.
Dec 20 06:45:32 thestash systemd: mosquitto.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mosquitto.service has entered the 'failed' state with result 'exit-code'.
Dec 20 06:45:32 thestash systemd: Failed to start Mosquitto MQTT Broker.
-- Subject: A start job for unit mosquitto.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mosquitto.service has finished with a failure.
--
-- The job identifier is 4794 and the job result is failed.
Dec 20 06:45:34 thestash sudo: admin : TTY=pts/0 ; PWD=/home/admin ; USER=root ; COMMAND=/usr/bin/nano /etc/mosquitto/conf.d/default.conf
Dec 20 06:45:34 thestash sudo: pam_unix(sudo:session): session opened for user root by admin(uid=0)
Dec 20 06:45:38 thestash sudo: pam_unix(sudo:session): session closed for user root
Dec 20 06:45:38 thestash kernel: [UFW BLOCK] IN=eth0 OUT= MAC=d6:32:76:db:0a:3b:18:2a:d3:e0:df:f0:08:00 SRC=45.129.33.168 DST=104.236.7.145 LEN=40 TOS=0x00 PREC=0x00 TTL=245 ID=11309 PROTO=TCP SPT=59534 DPT=21661 WINDOW=1024 RES=0x00 SYN URGP=0
Dec 20 06:45:44 thestash sudo: admin : TTY=pts/0 ; PWD=/home/admin ; USER=root ; COMMAND=/usr/bin/journalctl -xe
Dec 20 06:45:44 thestash sudo: pam_unix(sudo:session): session opened for user root by admin(uid=0)
If I comment out the keyfile
lines in my default.conf, the service restarts without error. The keys are there and do not seem to cause problems for anything else on my server.
And the mosquitto.log file indicates that it is indeed a problem with reading the certificate. A permissions issue seems like a good guess, but I don't see why that would be a problem only for privkey.pem
but not the other two files, which also have the same permissions. Also, nginx can use my certificates without owning them.
1608463912: mosquitto version 2.0.3 starting
1608463912: Config loaded from /etc/mosquitto/mosquitto.conf.
1608463912: Opening ipv4 listen socket on port 1883.
1608463912: Opening ipv4 listen socket on port 8883.
1608463912: Opening ipv6 listen socket on port 8883.
1608463912: Error: Unable to load CA certificates. Check cafile "/etc/letsencrypt/live/mylittlestashbox.com/chain.pem".
1608463912: Error: Unable to load server certificate "/etc/letsencrypt/live/mylittlestashbox.com/cert.pem". Check certfile.
1608463912: OpenSSL Error: error:0200100D:system library:fopen:Permission denied
1608463912: OpenSSL Error: error:20074002:BIO routines:file_ctrl:system lib
1608463912: OpenSSL Error: error:140DC002:SSL routines:use_certificate_chain_file:system lib
1608464267: mosquitto version 2.0.3 starting
1608464267: Config loaded from /etc/mosquitto/mosquitto.conf.
1608464267: Opening ipv4 listen socket on port 1883.
1608464267: Opening ipv4 listen socket on port 8883.
1608464267: Opening ipv6 listen socket on port 8883.
1608464267: Error: Unable to load CA certificates. Check cafile "/etc/letsencrypt/live/mylittlestashbox.com/chain.pem".
/var/log/mosquitto/mosquitto.log
Stonecraft
(869 rep)
Dec 20, 2020, 06:14 PM
• Last activity: Jul 31, 2024, 01:36 AM
1
votes
2
answers
2317
views
Bash Script: To log MQTT feed to txt file
I have written a small bash script (datalogger.sh) to store the mqtt data on to SD card inside a linux machine. The bash script is as below:- #!/bin/bash fileNumber=1 temp=1 // flag to check and create new files fileName="Data" while [ $temp -le 1 ] do if [ -f "/media/card/$fileName$fileNumber.txt"...
I have written a small bash script (datalogger.sh) to store the mqtt data on to SD card inside a linux machine. The bash script is as below:-
#!/bin/bash
fileNumber=1
temp=1 // flag to check and create new files
fileName="Data"
while [ $temp -le 1 ]
do
if [ -f "/media/card/$fileName$fileNumber.txt" ]
then
((fileNumber++))
else
touch "/media/card/$fileName$fileNumber.txt"
mosquitto_sub -v -t "gateway/+/rx" | tee /media/card/$fileName$fileNumber.txt
temp=2
fi
done
The bash script works totally fine if i run it with the following command
./datalogger.sh
As of next step, i used the
update-rc.d datalogger.sh defaults
so that on boot the bash script automatically runs. However, i only get the empty text files. Could anyone guide me, what mistake i am making?
Best Regards,
Usman Asghar
(11 rep)
Aug 16, 2018, 05:37 PM
• Last activity: Apr 4, 2024, 07:04 PM
0
votes
0
answers
75
views
How to forward data via netns exec namespace
I'm using zmq to receive data from another pc. I would like to formard this received data to the Internet via namespace. I've created this python script: import subprocess import zmq context = zmq.Context() socket = context.socket(zmq.SUB) socket.connect("tcp://10.1.24.50:4000") socket.subscribe("")...
I'm using zmq to receive data from another pc. I would like to formard this received data to the Internet via namespace. I've created this python script:
import subprocess
import zmq
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://10.1.24.50:4000")
socket.subscribe("")
while True:
print("message rcv")
data = socket.recv_string()
command = ['sudo', 'ip', 'netns', 'exec', 'ue1', 'ping', '-i', '1', '-c', '1', '-s', str(len(data)), '8.8.8.8']
print(data)
subprocess.run(command, input=data, text=True)
When I execute the script in a terminal I get this output.
message rcv
Lat 41.283637867194834, Lon=1.9846894680137672
PING 8.8.8.8 (8.8.8.8) 46(74) bytes of data.
54 bytes from 8.8.8.8: icmp_seq=1 ttl=114 time=184 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 184.334/184.334/184.334/0.000 ms
However, I don't see the transmitted data (using wireshark).
What I'm doing wrong?
Raúl Parada Medina
(1 rep)
Mar 11, 2024, 04:19 PM
• Last activity: Mar 11, 2024, 08:16 PM
0
votes
0
answers
34
views
Is it possible to encrypt traffic if I have only CA certificate?
I have simple secure (I guess) `Mosquitto` server described in my [previous question][1]. Client machine has no any keys or certificate installed except single ca.crt certificate file generated and taken from `Mosquitto` server. Is it possible that request performed by simple `MQTT` client below is...
I have simple secure (I guess)
Mosquitto
server described in my previous question .
Client machine has no any keys or certificate installed except single ca.crt certificate file generated and taken from Mosquitto
server.
Is it possible that request performed by simple MQTT
client below is encrypted and secure?
mosquitto_sub -h 192.168.1.8 -t sensor --cafile ca.crt -p 8883 -d
This client uses only single certificate file and no keys. Is it somehow possible encrypt traffic by having only certificate and no keys?
vico
(843 rep)
Dec 18, 2019, 10:05 AM
• Last activity: Feb 11, 2024, 12:25 AM
4
votes
1
answers
2271
views
mosquitto bruteforce fail2ban failregex
I am trying to write fail2ban filter to block bruteforcing IP addresses which are trying to subscribe to username/password protected mosquitto service by guessing username/password combinations. On attempt to subscribe with incorrect details, mosquitto writes two lines to log like: 1544984465: New c...
I am trying to write fail2ban filter to block bruteforcing IP addresses which are trying to subscribe to username/password protected mosquitto service by guessing username/password combinations.
On attempt to subscribe with incorrect details, mosquitto writes two lines to log like:
1544984465: New connection from 123.123.123.123 on port 1883.
1544984465: Socket error on client , disconnecting.
I managed to write regex matching this two lines pattern by using https://regex101.com/ set to "python flavor". Regex looks like this:
\s(?P\d+)\: New connection from (?P[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) .+\n(?P=date): Socket error on client \, disconnecting.
Unfortunately, fail2ban is unable to find matches in log by using this regex:
# fail2ban-regex '/var/log/testlog.log' '\s(?P\d+)\: New connection from (?P[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) .+\n(?P=date): Socket error on client \, disconnecting.'
Running tests
=============
Use failregex line : \s(?P\d+)\: New connection from (?P[0-...
Use log file : /var/log/testlog.log
Use encoding : UTF-8
Results
=======
Failregex: 0 total
Ignoreregex: 0 total
Date template hits:
|- [# of hits] date format
| Epoch
`-
Lines: 13 lines, 0 ignored, 0 matched, 13 missed
[processed in 0.00 sec]
|- Missed line(s):
| 1544984465: New connection from 123.123.123.123 on port 1883.
| 1544984465: Socket error on client , disconnecting.
| 1544984466: New connection from 123.123.123.123 on port 1883.
| 1544984466: Socket error on client , disconnecting.
| 1544984468: New connection from 123.123.123.123 on port 1883.
| 1544984468: Socket error on client , disconnecting.
| 1544984469: New connection from 123.123.123.123 on port 1883.
| 1544984469: Socket error on client , disconnecting.
| 1544984470: New connection from 123.123.123.123 on port 1883.
| 1544984470: Socket error on client , disconnecting.
| 1544984471: New connection from 123.123.123.123 on port 1883.
| 1544984471: Socket error on client , disconnecting.
| 1544984473: New connection from 123.123.123.123 on port 1883.
`-
Fail2ban version is 0.9.6-1.el6.1. Running on Centos 6 server.
Nerijus
(66 rep)
Dec 16, 2018, 07:42 PM
• Last activity: Nov 20, 2023, 11:07 PM
0
votes
2
answers
700
views
How to run multiple mosquitto brokers on Debian 11?
I want to have 2 mosquitto brokers running on Debian 11, each with it's own configuration. I have one instance installed and running, but don't know how to start second. I'm a newbie so please answear as simply and clearly as possible
I want to have 2 mosquitto brokers running on Debian 11, each with it's own configuration.
I have one instance installed and running, but don't know how to start second.
I'm a newbie so please answear as simply and clearly as possible
Marek J.
(1 rep)
Mar 10, 2023, 11:18 AM
• Last activity: Mar 30, 2023, 07:20 AM
3
votes
2
answers
7838
views
MQTT Error: Connection Lost
A 'listener' console was setup: mosquitto_sub -h test.mosquitto.org -t "myTopic" -v `mosquitto_pub` returns an error: ``` pi@raspberrypi:~ $ mosquitto_pub -h test.mosquitto.org -t 'myTopic' -m 'hello world' **Error: The connection was lost.** ``` What steps, from the command line, can be taken to di...
A 'listener' console was setup:
mosquitto_sub -h test.mosquitto.org -t "myTopic" -v
mosquitto_pub
returns an error:
pi@raspberrypi:~ $ mosquitto_pub -h test.mosquitto.org -t 'myTopic' -m 'hello world'
**Error: The connection was lost.**
What steps, from the command line, can be taken to diagnose if there is a syntax problem?
Update:
Replacing the MQTT server with iot.eclipse.org
does not suffer the error and returns payloads as expected.
Listener console setup:
mosquitto_sub -h iot.eclipse.org -t "myTopic" -v
Send payload:
mosquitto_pub -h iot.eclipse.org -t 'myTopic' -m 'hello world'
mosquitto_pub
returns:
pi@raspberrypi:~ $ mosquitto_sub -h iot.eclipse.org -t "myTopic" -v
myTopic hello world
Publish a payload:
pi@raspberrypi:~ $ mosquitto_pub -h test.mosquitto.org -t 'myTopic' -m 'hello world'
Changing the MQTT broker demonstrates there is not a syntax error, however, the question remains why there is an error returned in the original testing
gatorback
(1522 rep)
Aug 6, 2019, 08:50 PM
• Last activity: Jun 27, 2022, 09:27 PM
0
votes
1
answers
664
views
ModuleNotFoundError running Python Script as systemd task
I have a Python script which I'd like to run at startup. However when I run it as a systemd service, it seems to be unable to find one of the modules. Here's the status message: ● mqttproc.service - MQTT Post-processor Loaded: loaded (/etc/systemd/system/mqttproc.service; enabled; vendor preset: ena...
I have a Python script which I'd like to run at startup. However when I run it as a systemd service, it seems to be unable to find one of the modules. Here's the status message:
● mqttproc.service - MQTT Post-processor
Loaded: loaded (/etc/systemd/system/mqttproc.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-12-06 11:10:45 GMT; 2min 31s ago
Process: 2375 ExecStart=/usr/bin/python3 /home/ken/python/mqttproc/mqttproc.py (code=exited, status=1/FAILURE)
Main PID: 2375 (code=exited, status=1/FAILURE)
Dec 06 11:10:45 MintVM systemd: Started MQTT Post-processor.
Dec 06 11:10:45 MintVM python3: Sensor positions [100.0, 80.0, 60.0, 40.0, 20.0, 0.0] (Litres)
Dec 06 11:10:45 MintVM python3: Traceback (most recent call last):
Dec 06 11:10:45 MintVM python3: File "/home/ken/python/mqttproc/mqttproc.py", line 131, in
Dec 06 11:10:45 MintVM python3: import paho.mqtt.client as mqtt
Dec 06 11:10:45 MintVM python3: ModuleNotFoundError: No module named 'paho'
Dec 06 11:10:45 MintVM systemd: mqttproc.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 11:10:45 MintVM systemd: mqttproc.service: Failed with result 'exit-code'.
The bizarre thing is this script runs without fail from the commandline. I even have it running as a systemd service on another machine. My .service file is as simple as they come:
[Unit]
Description=MQTT Post-processor
[Service]
ExecStart=/usr/bin/python3 /home/ken/python/mqttproc/mqttproc.py
WorkingDirectory=/home/ken/python/mqttproc
[Install]
WantedBy=multi-user.target
Can anyone point out the obvious thing I'm missing, please?
Thanks in advance.
KDM
(103 rep)
Dec 6, 2021, 11:23 AM
• Last activity: Dec 6, 2021, 02:23 PM
0
votes
1
answers
193
views
Trying to fit a complicated bash string into a mqtt message
I am trying to fit the output of the following string (that is a simple number) df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t into the following mqtt message mosquitto_pub -h 192.168.1.1 -p 1883 -u user -P password -t disk_usage/4tb -m *[here sould go the out...
I am trying to fit the output of the following string (that is a simple number)
df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t
into the following mqtt message
mosquitto_pub -h 192.168.1.1 -p 1883 -u user -P password -t disk_usage/4tb -m *[here sould go the output of the previous command]*
I have tried the following script and many many of its variants (different quotes and parentesis, etc.) but I still cannot figure it out.
#!/bin/sh
var1='{df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t}'
echo $var1
mosquitto_pub -h 192.168.1.65 -p 1883 -u mqtt -P mqtt_password -t GC01SRVR/disk_usage -m "{\"Content\": $var1}"
giovi321
(919 rep)
Nov 19, 2021, 06:54 PM
• Last activity: Nov 19, 2021, 07:15 PM
1
votes
1
answers
237
views
Recovering from USB dongle disconnection with systemd
If this is not the right place to post a this question, please say. I’m running zigbee2mqtt (Zigbee broker) on a USB dongle device (CC2531 with antenna, forgot the antenna model) and a Linux machine (KDE neon User Edition 5.19, based on Ubuntu 18.04). Sometimes zigbee2mqtt stops working and I have t...
If this is not the right place to post a this question, please say.
I’m running zigbee2mqtt (Zigbee broker) on a USB dongle device (CC2531 with antenna, forgot the antenna model) and a Linux machine (KDE neon User Edition 5.19, based on Ubuntu 18.04).
Sometimes zigbee2mqtt stops working and I have to change the ownership of the device (with chown) to successfully run it again. So I put it in one script:
~/my_services/zigbee2mqtt_service $ cat z2m.sh
sudo chown gal /dev/ttyACM0
cd /opt/zigbee2mqtt
npm start
and created a service in systemd to run the script:
~/my_services/zigbee2mqtt_service $ systemctl cat zigbee2mqtt.service
# /etc/systemd/system/zigbee2mqtt.service
[Unit]
Description=zigbee2mqtt
After=network.target
[Service]
# ExecStart=/usr/local/bin/npm start
# WorkingDirectory=/opt/zigbee2mqtt
ExecStart=/home/gal/my_services/zigbee2mqtt_service/z2m.sh
StandardOutput=inherit
StandardError=inherit
Restart=always
User=gal
[Install]
WantedBy=multi-user.target
This used to work, but for some reason, now the service won't start. I’m tried enabling it, starting manually, and to reload daemon. If I run the z2m.sh script manually it works well, but I’m working from a remote machine so I have to disconnect, which stops zigbee2mqtt.
It’d be great if you can point me to what to fix, or to a different way to recover from the ‘revoked ownership’.
Edit:
This is what I get when checking the service status:
~ $ systemctl status zigbee2mqtt.service
● zigbee2mqtt.service - zigbee2mqtt
Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; vendor pres
Active: failed (Result: exit-code) since Mon 2020-07-20 11:00:57 IDT; 2 days
Process: 4059 ExecStart=/home/gal/my_services/zigbee2mqtt_service/z2m.sh (code
Main PID: 4059 (code=exited, status=203/EXEC)
Jul 20 11:00:57 phoenix systemd: zigbee2mqtt.service: Service hold-off time o
Jul 20 11:00:57 phoenix systemd: zigbee2mqtt.service: Scheduled restart job,
Jul 20 11:00:57 phoenix systemd: Stopped zigbee2mqtt.
Jul 20 11:00:57 phoenix systemd: zigbee2mqtt.service: Start request repeated
Jul 20 11:00:57 phoenix systemd: zigbee2mqtt.service: Failed with result 'exi
Jul 20 11:00:57 phoenix systemd: Failed to start zigbee2mqtt.
lines 1-12/12 (END)
Gal
(661 rep)
Jul 22, 2020, 03:37 PM
• Last activity: Jul 25, 2020, 12:40 PM
0
votes
1
answers
450
views
Disable client SSL certificate
I have generated client key certificate on self signed secure `Mosquitto` server. I have copied CA and client certificate with client key into client machine. Client subscription runs fine: mosquitto_sub -h 192.168.1.8 -t sensor --cafile ca.crt --cert client.crt --key client.key -p 8883 -d But what...
I have generated client key certificate on self signed secure
Mosquitto
server. I have copied CA and client certificate with client key into client machine. Client subscription runs fine:
mosquitto_sub -h 192.168.1.8 -t sensor --cafile ca.crt --cert client.crt --key client.key -p 8883 -d
But what if somebody hack my client machine and will get credentials. How I can disable this certificate in server machine?
vico
(843 rep)
Dec 31, 2019, 09:24 AM
• Last activity: Dec 31, 2019, 01:48 PM
0
votes
1
answers
124
views
Ensure TLS communication security in Mosquitto
I have simple MQTT Mosquitto server that I'm trying to make secure. Mosquitto.conf: log_type all password_file /etc/mosquitto/mosquitto_users.txt pid_file /var/run/mosquitto.pid persistence true persistence_location /var/lib/mosquitto/ port 8883 cafile /etc/mosquitto/ca_certificates/ca.crt keyfile /...
I have simple MQTT Mosquitto server that I'm trying to make secure.
Mosquitto.conf:
log_type all
password_file /etc/mosquitto/mosquitto_users.txt
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
port 8883
cafile /etc/mosquitto/ca_certificates/ca.crt
keyfile /etc/mosquitto/ca_certificates/server.key
certfile /etc/mosquitto/ca_certificates/server.crt
tls_version tlsv1
On current server I generated:
CA certificate
openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
Server certificate:
openssl genrsa -out server.key 2048
openssl req -new -out server.csr -key server.key
Self sign server certificate:
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 720
All required files placed according to
msoquitto.conf
configuration.
I'm using following commands to subscribe and post messages by using ca.crt
certificate.
mosquitto_sub -h 192.168.1.8 -t sensor --cafile ca.crt -p 8883 -d
mosquitto_pub -h 192.168.1.8 -t sensor --cafile ca.crt -m "test" -p 8883 -d
Everything works fine. But does it men communication is secured? Should I place server on Internet and nobody will grab information?
vico
(843 rep)
Dec 17, 2019, 02:26 PM
• Last activity: Dec 18, 2019, 11:08 AM
0
votes
1
answers
82
views
Can the MQTT output be inferred from test server instructions?
A test MQTT broker can be found at: [http://test.mosquitto.org/][1]. The website suggests trying the command: mosquitto_sub -h test.mosquitto.org -t "#" -v I believe that the "#" denote a wildcard for topics, which would show any topic and its payload. A raspberry pi has successfully run the mosquit...
A test MQTT broker can be found at: http://test.mosquitto.org/ . The website suggests trying the command:
mosquitto_sub -h test.mosquitto.org -t "#" -v
I believe that the "#" denote a wildcard for topics, which would show any topic and its payload.
A raspberry pi has successfully run the mosquitto command per instructables MQTT example , however **no output is observed with the above command.**
It is unclear if there is an entity publishing to the test server that would return a result in the subscribing client. This could be on reason that I am not observing anything. I would think there are other possible obstacles / pitfalls and look forward to enlightening responses.
Attempts to publish to a topic failed as described in: https://unix.stackexchange.com/questions/534236/
gatorback
(1522 rep)
Aug 6, 2019, 08:07 PM
• Last activity: Aug 7, 2019, 02:48 PM
0
votes
0
answers
161
views
Why does MQTT Mosquito attempt ot remove a package?
Context: OSMC distro on Raspberry Pi Zero-W. MQTT Mosquitto package installation failed. Why would an attempt to: `sudo apt-get install mosquitto` trigger an attempt to remove an OSMC package? The following packages will be REMOVED: ssh-app-osmc Log: osmc@osmczero:~$ sudo apt-get install mosquitto R...
Context: OSMC distro on Raspberry Pi Zero-W. MQTT Mosquitto package installation failed.
Why would an attempt to:
sudo apt-get install mosquitto
trigger an attempt to remove an OSMC package?
The following packages will be REMOVED:
ssh-app-osmc
Log:
osmc@osmczero:~$ sudo apt-get install mosquitto
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libev4 libuv1 libwebsockets8
Suggested packages:
apparmor
The following packages will be REMOVED:
ssh-app-osmc
The following NEW packages will be installed:
libev4 libuv1 libwebsockets8 mosquitto
0 upgraded, 4 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/314 kB of archives.
After this operation, 673 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 34694 files and directories currently installed.)
Removing ssh-app-osmc (1.2.3) ...
Removing 'diversion of /etc/ssh/sshd_config to /etc/ssh/sshd_config.distributed by ssh-app-osmc'
dpkg-divert: error: rename involves overwriting '/etc/ssh/sshd_config' with
different file '/etc/ssh/sshd_config.distributed', not allowed
dpkg: error processing package ssh-app-osmc (--remove):
subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
ssh-app-osmc
E: Sub-process /usr/bin/dpkg returned an error code (1)
UPDATE
===
Dependency query:
osmc@osmczero:~$ apt-cache show ssh-app-osmc
Package: ssh-app-osmc
Origin: OSMC
Version: 1.2.3
Essential: No
Pre-Depends: openssh-server
Architecture: all
Maintainer: Sam G Nazarko
Priority: required
Section: metapackages
Filename: pool/main/s/ssh-app-osmc/ssh-app-osmc_1.2.3_all.deb
Size: 3168
SHA256: 6fe60f2956b2d5105d9da82693f1747195be55ce81a6e4b4085ab5acc0af33fb
SHA1: edcb33f8a2f0ed82028e31e53ae6889dc99714f5
MD5sum: 9602092e26c9fe46596dc2165759b78d
Description: SSH server for OSMC with prepopulated configuration
Description-md5: a4e3a71ca28452ae99a476d87b31377c
Installed-Size: 38
gatorback
(1522 rep)
Aug 2, 2019, 01:36 AM
• Last activity: Aug 2, 2019, 03:52 AM
1
votes
1
answers
2045
views
mosquitto_sub –d –t armtronix_mqtt Error: Unknown option '–d'
What information can be gleaned for corrective action to enable subscription to the example MQTT topic? The goal is to reproduce the test (subscribe & publish), per the [instruction's Step 3][1]: an MQTT server was installed and attempts to subscribe with MQTT Client fails: pi@raspberrypi:~ $ mosqui...
What information can be gleaned for corrective action to enable subscription to the example MQTT topic?
The goal is to reproduce the test (subscribe & publish), per the instruction's Step 3 : an MQTT server was installed and attempts to subscribe with MQTT Client fails:
pi@raspberrypi:~ $ mosquitto_sub –d –t armtronix_mqtt
**Error: Unknown option '–d'.**
Use 'mosquitto_sub --help' to see usage.
Help Page:
pi@raspberrypi:~ $ mosquitto_sub --help
mosquitto_sub is a simple mqtt client that will subscribe to a single topic and print all messages it receives.
mosquitto_sub version 1.4.10 running on libmosquitto 1.4.10.
Usage: mosquitto_sub [-c] [-h host] [-k keepalive] [-p port] [-q qos] [-R] -t topic ...
[-C msg_count] [-T filter_out]
[-A bind_address] [-S]
[-i id] [-I id_prefix]
[-d] [-N] [--quiet] [-v]
[-u username [-P password]]
[--will-topic [--will-payload payload] [--will-qos qos] [--will-retain]]
[{--cafile file | --capath dir} [--cert file] [--key file]
[--ciphers ciphers] [--insecure]]
[--psk hex-key --psk-identity identity [--ciphers ciphers]]
[--proxy socks-url]
mosquitto_sub --help
-A : bind the outgoing socket to this host/ip address. Use to control which interface
the client communicates over.
-c : disable 'clean session' (store subscription and pending messages when client disconnects).
-C : disconnect and exit after receiving the 'msg_count' messages.
-d : enable debug messages.
-h : mqtt host to connect to. Defaults to localhost.
-i : id to use for this client. Defaults to mosquitto_sub_ appended with the process id.
-I : define the client id as id_prefix appended with the process id. Useful for when the
broker is using the clientid_prefixes option.
-k : keep alive in seconds for this client. Defaults to 60.
-N : do not add an end of line character when printing the payload.
-p : network port to connect to. Defaults to 1883.
-P : provide a password (requires MQTT 3.1 broker)
-q : quality of service level to use for the subscription. Defaults to 0.
-R : do not print stale messages (those with retain set).
-S : use SRV lookups to determine which host to connect to.
-t : mqtt topic to subscribe to. May be repeated multiple times.
-T : topic string to filter out of results. May be repeated.
-u : provide a username (requires MQTT 3.1 broker)
-v : print published messages verbosely.
-V : specify the version of the MQTT protocol to use when connecting.
Can be mqttv31 or mqttv311. Defaults to mqttv31.
--help : display this message.
--quiet : don't print error messages.
--will-payload : payload for the client Will, which is sent by the broker in case of
unexpected disconnection. If not given and will-topic is set, a zero
length message will be sent.
--will-qos : QoS level for the client Will.
--will-retain : if given, make the client Will retained.
--will-topic : the topic on which to publish the client Will.
--cafile : path to a file containing trusted CA certificates to enable encrypted
certificate based communication.
--capath : path to a directory containing trusted CA certificates to enable encrypted
communication.
--cert : client certificate for authentication, if required by server.
--key : client private key for authentication, if required by server.
--ciphers : openssl compatible list of TLS ciphers to support.
--tls-version : TLS protocol version, can be one of tlsv1.2 tlsv1.1 or tlsv1.
Defaults to tlsv1.2 if available.
--insecure : do not check that the server certificate hostname matches the remote
hostname. Using this option means that you cannot be sure that the
remote host is the server you wish to connect to and so is insecure.
Do not use this option in a production environment.
--psk : pre-shared-key in hexadecimal (no leading 0x) to enable TLS-PSK mode.
--psk-identity : client identity string for TLS-PSK mode.
--proxy : SOCKS5 proxy URL of the form:
socks5h://[username[:password]@]hostname[:port]
Only "none" and "username" authentication is supported.
MQTT Client install log:
pi@raspberrypi:~ $ sudo apt-get install mosquitto-clients
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
coinor-libipopt1v5 libmumps-seq-4.10.0 libraw15
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libmosquitto1
The following NEW packages will be installed:
libmosquitto1 mosquitto-clients
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 99.5 kB of archives.
After this operation, 222 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libmosquitto1 armhf 1.4.10-3+deb9u4 [47.2 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian stretch/main armhf mosquitto-clients armhf 1.4.10-3+deb9u4 [52.3 kB]
Fetched 99.5 kB in 1s (86.7 kB/s)
Selecting previously unselected package libmosquitto1:armhf.
(Reading database ... 141867 files and directories currently installed.)
Preparing to unpack .../libmosquitto1_1.4.10-3+deb9u4_armhf.deb ...
Unpacking libmosquitto1:armhf (1.4.10-3+deb9u4) ...
Selecting previously unselected package mosquitto-clients.
Preparing to unpack .../mosquitto-clients_1.4.10-3+deb9u4_armhf.deb ...
Unpacking mosquitto-clients (1.4.10-3+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libmosquitto1:armhf (1.4.10-3+deb9u4) ...
Setting up mosquitto-clients (1.4.10-3+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
.list
file install for Raspbian buster:
pi@raspberrypi:~ $ cd /etc/apt/sources.list.d/
pi@raspberrypi:/etc/apt/sources.list.d $ sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
--2019-08-01 00:01:16-- http://repo.mosquitto.org/debian/mosquitto-buster.list
Resolving repo.mosquitto.org (repo.mosquitto.org)... 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [application/octet-stream]
Saving to: ‘mosquitto-buster.list’
mosquitto-buster.list 100%[===================================================================>] 50 --.-KB/s in 0s
2019-08-01 00:01:17 (1.14 MB/s) - ‘mosquitto-buster.list’ saved [50/50]
pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub –t armtronix_mqtt
Error: Unknown option '–t'.
Use 'mosquitto_sub --help' to see usage.
pi@raspberrypi:/etc/apt/sources.list.d $ sudo apt-get install mosquitto-clients
Reading package lists... Done
Building dependency tree
Reading state information... Done
mosquitto-clients is already the newest version (1.4.10-3+deb9u4).
The following packages were automatically installed and are no longer required:
coinor-libipopt1v5 libmumps-seq-4.10.0 libraw15
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub –t armtronix_mqtt
Error: Unknown option '–t'.
Use 'mosquitto_sub --help' to see usage.
pi@raspberrypi:/etc/apt/sources.list.d $ mosquitto_sub -d –t armtronix_mqtt
Error: Unknown option '–t'.
Use 'mosquitto_sub --help' to see usage.
gatorback
(1522 rep)
Aug 1, 2019, 04:06 AM
• Last activity: Aug 2, 2019, 02:10 AM
1
votes
1
answers
35
views
Raspbian default MQTT Server?
As I understand it, Raspbian (```2019-04-08-raspbian-stretch-full.img```) features Node-Red out of the box. I have seen the youTube examples that show [Node-Red configuring an MQTT server][1] and left to wonder does the Raspbian image already have an MQTT server? If a default broker is installed,how...
As I understand it, Raspbian (
-04-08-raspbian-stretch-full.img
) features Node-Red out of the box.
I have seen the youTube examples that show Node-Red configuring an MQTT server and left to wonder does the Raspbian image already have an MQTT server?
If a default broker is installed,how does one 'smoke test' the broker?
I would like to understand how to test (from the command line) if an MQTT server is installed, so I can determine if I need to install MQTT on the rPi.
gatorback
(1522 rep)
Jul 26, 2019, 06:59 PM
• Last activity: Jul 27, 2019, 07:10 PM
3
votes
1
answers
6579
views
installing eclipse/paho.mqtt c++ client on Debian
I'm developing a C++ program (for a home IoT Project) on Debian 9 that needs to act as an MQTT client. I found paho.mqtt would be helpful in this regard, but none of the on-line documentations to install it worked so far. Does anyone has any experience on getting paho mqtt c++ client to work on Debi...
I'm developing a C++ program (for a home IoT Project) on Debian 9 that needs to act as an MQTT client.
I found paho.mqtt would be helpful in this regard, but none of the on-line documentations to install it worked so far.
Does anyone has any experience on getting paho mqtt c++ client to work on Debian 9?
If so, could you help me with the steps I need to do to get it working?
(My Backgroud : I'm pretty comfortable around Linux, kind of OK when it comes to writing code in C or C++, but not that familiar with how c++ compiler works or how to get get C++ header files available for my program in this case)
Thanks in advance!
ChinM
(33 rep)
Jul 1, 2019, 03:30 AM
• Last activity: Jul 2, 2019, 07:39 AM
1
votes
0
answers
385
views
Error compiling mosquitto_auth_plug
My `config.mk` file has the following settings: # Select your backends from this list BACKEND_CDB ?= no BACKEND_MYSQL ?= no BACKEND_SQLITE ?= no BACKEND_REDIS ?= no BACKEND_POSTGRES ?= yes BACKEND_LDAP ?= no BACKEND_HTTP ?= no BACKEND_JWT ?= no BACKEND_MONGO ?= no BACKEND_FILES ?= yes BACKEND_MEMCAC...
My
config.mk
file has the following settings:
# Select your backends from this list
BACKEND_CDB ?= no
BACKEND_MYSQL ?= no
BACKEND_SQLITE ?= no
BACKEND_REDIS ?= no
BACKEND_POSTGRES ?= yes
BACKEND_LDAP ?= no
BACKEND_HTTP ?= no
BACKEND_JWT ?= no
BACKEND_MONGO ?= no
BACKEND_FILES ?= yes
BACKEND_MEMCACHED ?= no
# Specify the path to the Mosquitto sources here
MOSQUITTO_SRC = /usr/include
# Specify the path the OpenSSL here
OPENSSLDIR = /usr/bin/openssl
# Specify optional/additional linker/compiler flags here
# On macOS, add
# CFG_LDFLAGS = -undefined dynamic_lookup
# as described in https://github.com/eclipse/mosquitto/issues/244
CFG_LDFLAGS =
CFG_CFLAGS = -DRAW_SALT
When i am trying to compile it sudo make
it throws the following error:
Selected backends: PostgreSQL Files
Using mosquitto source dir: /usr/include
OpenSSL install dir: /usr/bin/openssl
If you changed the backend selection, you might need to 'make clean' first
CFLAGS: -DRAW_SALT -I/usr/include/src/ -I/usr/include/lib/ -fPIC -Wall -Werror -DBE_POSTGRES -DBE_FILES -I/usr/include/postgresql -I/src -DDEBUG=1 -I/usr/bin/openssl /include
LDFLAGS: -L/usr/include/lib/
LDADD: -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/bin/openssl /lib -lcrypto -lmosquitto
cc -DRAW_SALT -I/usr/include/src/ -I/usr/include/lib/ -fPIC -Wall -Werror -DBE_POSTGRES -DBE_FILES -Ipg_config --includedir
-I/src -DDEBUG=1 -I/usr/bin/openssl /include -c -o auth-plug.o auth-plug.c
cc: error: /include: No such file or directory
: recipe for target 'auth-plug.o' failed
make: *** [auth-plug.o] Error 1
Could you please advice whats wrong and how can i fix the problem?
ussrback
(155 rep)
Mar 25, 2019, 02:15 PM
1
votes
1
answers
3648
views
Where is mosquitto source directory located?
I want to compile mosquitto-auth-plugin, which requires configuration of `config.mk` file, where one of the required parameter is to Specify the path to the Mosquitto sources `MOSQUITTO_SRC =`.Could you please advice which directory i have to indicate if mosquitto was installed using advanced packag...
I want to compile mosquitto-auth-plugin, which requires configuration of
config.mk
file, where one of the required parameter is to Specify the path to the Mosquitto sources MOSQUITTO_SRC =
.Could you please advice which directory i have to indicate if mosquitto was installed using advanced package tool (apt)?
ussrback
(155 rep)
Mar 24, 2019, 08:32 AM
• Last activity: Mar 25, 2019, 11:39 AM
2
votes
2
answers
1690
views
MQTT as a variable on Bash?
Hi I want to try and convert a message receieved from MQTT into a variable so I can do an "IF script" using messages sent from a certain topic on mqtt. I tried this at top of script but didn't work: Message = mosquitto_sub -d -t "test/test" Thank you
Hi I want to try and convert a message receieved from MQTT into a variable so I can do an "IF script" using messages sent from a certain topic on mqtt.
I tried this at top of script but didn't work:
Message = mosquitto_sub -d -t "test/test"
Thank you
Gundam0079
(31 rep)
Jan 3, 2019, 02:02 PM
• Last activity: Mar 11, 2019, 09:57 AM
Showing page 1 of 20 total questions