Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] How to create users using php or javascript in mosquitto

Hi,

If I implement mosquitto-auth(MySql), how to connect mqtt client, I mean what I give in username and passwords?

client.connect({userName : "srinivas",password : "123456",onSuccess:onConnect,onFailure:doFail});

Thanks



On Tue, Jul 26, 2016 at 9:35 PM, bitfreak <bitfreak25@xxxxxx> wrote:
I've heard that using exec() in php could maybe unsafe, because you give the user access to your commandline. Especially when you use a variable like $userName in your command.

If you want a more secure implementation I recommend the mosquitto-auth-plugin (see: https://github.com/jpmens/mosquitto-auth-plug). It saves your users in MySQL or other supported databases, so you have a more dynamically access to it.


Am 26.07.2016 um 14:58 schrieb Kees Nuyt:
On Tue, 26 Jul 2016 17:30:23 +0530, you wrote:

Hi,

I use this code:

$userName = "srinivas";
$RndPsw  = "123456";
try{
    $command = "mosquitto_passwd -c /etc/mosquitto/passwd ".$userName." ".
$RndPsw ;
    exec($command , $out );
    print_r($out);
}catch(Exception $e){
    echo $e;
}
but not working getting empty response and user not created

when i execute only this command = "mosquitto_passwd -c
/etc/mosquitto/passwd ".$userName, getting response

Array ( [0] => Password: )

You probably have to add the -b option.

man mosquitto_passwd

   -b   Run in batch mode. This allows the password to be
provided at the command line which can be convenient but should
be used with care because the password will be visible on the
command line and in command history.



help me

Thanks
Srinivas



On Tue, Jul 26, 2016 at 5:01 PM, Carmelo G. <web@xxxxxxxxxx> wrote:

Hi

i use this code in php

$userName = "myUsername";
$RndPsw  = "myPassword";

$command = "mosquitto_passwd -b /var/www/MQTT/users ".$userName." ".
$RndPsw ;
exec($command , $out );
$mystring = "mosquitto";
exec("ps aux | grep \"${mystring}\" | grep -v grep | awk '{ print $2 }' |
head -1", $out); // find process
exec("kill -1 " .$out[0]);  // reset mosquitto

On 07/26/2016 12:49 PM, Srinivas Pokala wrote:

Hi,

Username successfully created using linux command with:  "mosquitto_passwd
/etc/mosquitto/passwd guest".

I need to create same with php or _javascript_ how?

Thanks
Srinivas


_______________________________________________
mosquitto-dev mailing listmosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visithttps://dev.eclipse.org/mailman/listinfo/mosquitto-dev



_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


_______________________________________________
mosquitto-dev mailing list
mosquitto-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top