MQTT Mosquitto Handing: Unterschied zwischen den Versionen
(→Fazit) |
|||
Zeile 1: | Zeile 1: | ||
== Eclipse Mosquitto MQTT Broker unter Ubuntu installieren und einrichten == | == Eclipse Mosquitto MQTT Broker unter Ubuntu installieren und einrichten == | ||
'''MQTT''' steht für ''Message Queuing Telemetry Transport'' und ist ein Protokoll für die Machine-to-Machine-Kommunikation im ''Internet of Things''. Eclipse Mosquitto ist ein beliebter Open-Source MQTT-Broker. | '''MQTT''' steht für ''Message Queuing Telemetry Transport'' und ist ein Protokoll für die Machine-to-Machine-Kommunikation im ''Internet of Things''. Eclipse Mosquitto ist ein beliebter Open-Source MQTT-Broker. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== Installiere deinen Broker === | === Installiere deinen Broker === | ||
− | + | *apt-get update && apt-get upgrade | |
− | + | *apt-get install mosquitto | |
− | apt-get update && apt-get upgrade | + | *apt-get install mosquitto-clients |
− | apt-get install mosquitto | ||
− | apt-get install mosquitto-clients | ||
− | |||
− | |||
=== Sichere deinen Broker mit einem Passwort ab === | === Sichere deinen Broker mit einem Passwort ab === | ||
− | + | *mosquitto_passwd -c /etc/mosquitto/passwd testuser | |
− | + | *nano /etc/mosquitto/conf.d/default.conf | |
− | mosquitto_passwd -c /etc/mosquitto/passwd testuser | ||
− | nano /etc/mosquitto/conf.d/default.conf | ||
</source> | </source> | ||
− | |||
− | |||
allow_anonymous false | allow_anonymous false | ||
password_file /etc/mosquitto/passwd | password_file /etc/mosquitto/passwd | ||
</source> | </source> | ||
− | + | *systemctl restart mosquitto | |
− | |||
− | systemctl restart mosquitto | ||
− | |||
=== Installiere und führe Certbot für Let's Encrypt Zertifikate aus === | === Installiere und führe Certbot für Let's Encrypt Zertifikate aus === |
Version vom 12. April 2024, 14:29 Uhr
Eclipse Mosquitto MQTT Broker unter Ubuntu installieren und einrichten
MQTT steht für Message Queuing Telemetry Transport und ist ein Protokoll für die Machine-to-Machine-Kommunikation im Internet of Things. Eclipse Mosquitto ist ein beliebter Open-Source MQTT-Broker.
Installiere deinen Broker
- apt-get update && apt-get upgrade
- apt-get install mosquitto
- apt-get install mosquitto-clients
Sichere deinen Broker mit einem Passwort ab
- mosquitto_passwd -c /etc/mosquitto/passwd testuser
- nano /etc/mosquitto/conf.d/default.conf
</source> allow_anonymous false password_file /etc/mosquitto/passwd </source>
- systemctl restart mosquitto
Installiere und führe Certbot für Let's Encrypt Zertifikate aus
Füge das Certbot-PPA hinzu und installiere Certbot:
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install certbot
ufw allow http
Erstelle und erneuere SSL-Zertifikate automatisch:
certbot certonly --standalone --preferred-challenges http-01 -d DNSDomainname
15 3 * * * certbot renew --noninteractive --post-hook "systemctl restart mosquitto"
Aktiviere SSL-Verschlüsselung für deinen Broker
Konfiguriere SSL in der Mosquitto-Konfigurationsdatei:
nano /etc/mosquitto/conf.d/default.conf
Füge folgende SSL-Parameter hinzu:
listener 8883
certfile /etc/letsencrypt/live/DNSDomainname/cert.pem
cafile /etc/letsencrypt/live/DNSDomainname/chain.pem
keyfile /etc/letsencrypt/live/DNSDomainname/privkey.pem
Aktualisiere die Firewall, um SSL-Verbindungen zuzulassen:
ufw allow 8883
Aktiviere Websockets für deinen Broker
Füge die Websocket-Unterstützung in der Mosquitto-Konfigurationsdatei hinzu:
nano /etc/mosquitto/conf.d/default.conf
Füge folgende Zeile für Websockets hinzu:
listener 9001
protocol websockets
Fazit
Die Einrichtung von Mosquitto als MQTT-Broker auf Ubuntu bietet eine robuste Plattform für IoT-Kommunikation. Durch die Sicherung des Brokers und die Aktivierung von SSL wird eine sichere Datenübertragung gewährleistet.