Setting up Authentication for your Mosquitto MQTT Broker

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey there welcome to another raspberry pi tutorial part of easyprogramming.net this is the continuation of the mqtt tutorial that i did back in november where i showed you how to set up mosquito and a python subscriber as a service on your raspberry pi there's a bigger work that i plan on doing which is explained here today i want to show you very quickly how to set up authentication on your mqtt service so you can set up some security the first thing you want to do is you want to type in mosquito if you type tab press tab a couple of times you'll see the options that are available to you and we want to look at password if we do h you'll see the options that are available for you we'll look at both c and u so the first thing is if you type in mosquito password see it'll create a file for you and and uh and manage it for you so if you type in the password file we'll just call it pw and the username i'm going to put is nas it'll ask you for a password i'll just type in password if i say list you'll see that pw file was created so we'll do nano pw you'll see that the username and the long hash of password is created so this is what we can use to authenticate the second way of doing this is to use the u command so the first thing before you use that we need to create a file that we need we'll call it password so we'll set up the file a plain text file and set up the username and password like this you can set up as as as many usernames and passwords as you want so i'll just do that as well then we'll do mosquito password u and the password file we called it password you need sudo so they can write list and then if we do nano password you'll see that it took both my usernames nas and one and and hashed the passwords so that it looks like this with the c command if you use this to create the file you can also use delete to delete files uh this should also work with the you as well so we want to take our password file and move it to its appropriate location so we'll we'll say we'll copy the password file to mosquito here so we'll do we'll go here we have the password file here now we want to update the mosquito configuration file so we don't know one thing i want to mention is that you can actually get document examples uh from this file here for some reason the dot example doesn't exist when i when i install this you can also get more information on mosquito.org on the mosquito configuration page here the two things we want to do here the first thing we want to do is we want to turn off uh anonymous authentication so we'll do allow us is false next we want to do is we want to define where the password file is located so for us it's pc must slash pw that's why i moved here right yeah next thing we'll do is sudo service mosquito restart and you'll see here that i was actually disconnected from uh from the raspberry pi so i don't know why i authenticated so i had this saved so i'm just gonna disconnect it i'm gonna reconnect it so i'm gonna do our if i try to authenticate without anything it says you know disconnected i can't authenticate if i put in my username and password i am now authenticated so i can subscribe and talk to myself with publish there we go so now i'm authenticated i can i can break it using something else and now this will not work anyways here's uh i hope this was quick and easy for you to learn how to set up authentication on your raspberry on your mosquito server come back to the next tutorial where i'll show you how to bridge two mosquito brokers to mptc brokers and hopefully we'll be able to control some lights on our internal network without exposing ourselves to the outside world if you have any questions do ask i'll have the configuration some more information on the github that i posted earlier i'll use the same same github repo as well so anyways hope you have a really good 2021 2020 is over thanks for watching have a great one
Info
Channel: Nazmus Nasir
Views: 6,419
Rating: undefined out of 5
Keywords: tutorial, software, help, tips, tricks, learn, technology, simple, tips and tricks, educational, programming tutorial, education, nazmus, easyprogramming.net, easy javascript, javascript, JavaScript tutorial, jquery, beginner programming, webdev, web development, js tutorial, beginner javascript, javascript console, document object model, easy js, how to, raspberry pi, python, mqtt, mosquitto, automation, home automation, hassio, mqttlens, systemd, service, authentication, login, secure mqtt, mqtt auth
Id: wIiI1yaJ_9s
Channel Id: undefined
Length: 5min 0sec (300 seconds)
Published: Sat Jan 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.