FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
233 views 9 comments
by anonymous
Hello

I create MQTT broker on rut955 ,set user password at mqtt publisher and create MQTT at Data to server with user credential

when subscribe Topic without user password, i can subscribe data

i want to set user password for subscribe mqtt Topic

1 Answer

0 votes
by anonymous

Hello,

To use passwords with the MQTT broker, you need a file with usernames and passwords. The password in the file also needs to be hashed. So the initial content of the passwordfile.txt could be:

  • username1:password123

Then, if you are using Linux and have mosquitto installed, the following command can be used to hash the password in the file:

  • mosquitto_passwd -U passwordfile.txt

The command should hash the password in the file. Then, you can upload the file to the MQTT broker in Services -> MQTT -> Broker -> Broker settings -> Miscellaneous.

Then, the file needs to be uploaded via WebUI.

If you want to restrict access for anonymous users, make sure you disable the 'Allow anonymous' option on that page as well.

Another thing to mention is that, when users fail to authenticate with the broker, their attempt is added to the IP block list. These can be viewed and unblocked in System -> Administration -> Access Control -> Security.

Kind Regards,

Andzej

by anonymous

Hi Andzej

                I follow your method but I am struck at opkg update and opkg install mosquito. Detail as attachment file

                https://community.teltonika-networks.com/?qa=blob&qa_blobid=15057754759170545636

                https://community.teltonika-networks.com/?qa=blob&qa_blobid=16126974202147092677

                After I Browse passwordfile.txt and try to run mosquitto_passwd -U passwordfile.txt

                root@RUT955:~# mosquitto_passwd -U passwordfile.txt                                                                          Error: Unable to open password file passwordfile.txt. No such file or directory.

by anonymous

Hello,

It seems that the txt file does not exist. You need to have a txt file with usernames and passwords:

You can use the following commands to create the file (admin is the username and admin01 is the password, you can change these):

  • echo "admin:admin01" > /tmp/password_file.txt
  • mosquitto_passwd -U /tmp/password_file.txt

Then, connect to the router with WinSCP and download password_file.txt from the /tmp folder. You can then upload this file to the broker in the WebUI settings. 

Alternatively, you can create a txt file with notepad on the PC and upload it to the router /tmp folder using WinSCP and hash the file with mosquitto_passwd command.

Kind Regards,

Andzej

by anonymous

1. after i command as follow



root@RUT955:~# echo "admin:admin01" > /tmp/password_file.txt
root@RUT955:~# mosquitto_passwd -U /tmp/password_file.txt
-ash: mosquitto_passwd: not found
2. I cannot access to RUT955 by winscp (access denied). i enable off ip bloack setting but cannot access
by anonymous
Hi,

Is it the same device? Have you tried again?

The first time it showed that the file does not exist, but the command was OK. The last time it showed that the command does not exist for some reason. It may be because of the duplicate mosquitto packages.

Also, when using WinSCP, make sure you use 'root' as username and password will be the same password you use for WebUI.

Kind Regards,

Andzej
by anonymous

yes it the same device 

I can access to rut955 via winscp but cannot run command as below

https://community.teltonika-networks.com/?qa=blob&qa_blobid=12818532530854816997

by anonymous

I can run mosquitto_passwd -U /tmp/password_file.txt

but i cannot use mqtt broker detail as picture below

https://community.teltonika-networks.com/?qa=blob&qa_blobid=12703885529674050269

https://community.teltonika-networks.com/?qa=blob&qa_blobid=45499631114301291

https://community.teltonika-networks.com/?qa=blob&qa_blobid=14631131272954662167

I remove password file, use without user password and cannot use mqtt broker too (before setting user password, i can use mqtt broker normally)

by anonymous

Hello,

After using the mosquitto_passwd command, did you download the file back and then uploaded it from the WebUI?

After this command, the file should look something like this:

Then, you need to upload this file via WebUI and it should work.

If it does not work after removing the passwords file, can you check:

  • IP block in System -> Administration -> Access Control -> Security.
  • Try restarting the mosquitto service with the following command:
    • /etc/init.d/mosquitto restart

Kind Regards,

by anonymous

Hello 

I can run mosquitto_passwd command and upload to mqtt broker webui

https://community.teltonika-networks.com/?qa=blob&qa_blobid=6739727128626689163

https://community.teltonika-networks.com/?qa=blob&qa_blobid=10015369940332410662

i try to set password at data to server and subscribe but cannot connect mqtt broker (both admin01 or password deifine in notepad)

i disable ip block and restart mosquitto service but didn't work

by anonymous
Hi,

I have sent you a private message.

Kind Regards,