Special characters issue in password

We are currently trying to resolve the duplicate issue-Mqtt

Recently I launched the hive-MQ setup- everything is fine.

but the problem is with the password of my user.

I have created two new users and passwords, one user password with a special character, and a second user password without a special character.

there is no problem with the second user(without special characters)

am not able to log in with the first user(with a special character)

please help out me with this issue.

Hi @mounika ,

It is great to see your interest in MQTT and HiveMQ broker, welcome to the community!

In order to help you please share which version of HiveMQ broker you use, which extension you use for client authentication, and your configs. Please make it clear which exact special character you use.

We will try to help you

Kind regards,
Dasha from HiveMQ team

Thanks for your response.

HiveMQ version 4.9.1

special character like ,+!@{}$%

My config file.

cat config.xml

<?xml version="1.0"?> 18756 0.0.0.0 true 8000 0.0.0.0 /mqtt mqttv3.1 mqtt false true
<cluster>
    <enabled>false</enabled>
</cluster>

<anonymous-usage-statistics>
    <enabled>true</enabled>
</anonymous-usage-statistics>

<control-center>
    <enabled>true</enabled>
    <listeners>
        <http>
            <port>8080</port>
            <bind-address>0.0.0.0</bind-address>
        </http>
</listeners>
<users>
        <user>
            <name>testuser</name>
            <password>e5b4881ea9c84501b7a50e03a3hgvhjkfbd1be138ad84a8fdd62f2c776ac526d</password>
        </user>
    </users>
</control-center>
<client-event-history>
            <enabled>true</enabled>
            <lifetime>86400</lifetime> <!-- 7 days -->
</client-event-history>

Hi @Daria_H

Am waiting for your response.

@mounika ,

Please specify the exact command that you used to generate the hash sum for the password present in the config.xml that you have shared.
Please specify in which OS (Windows, Linux, MacOS) and shell (bash, zsh, sh, cmd, PowerShell) the command has been executed.

Thank you,
Dasha from HiveMQ team

@Daria_H

LINUX:
echo -n userpassword | sha256sum
shell- CMD

@mounika ,

You indicated that you have an issue with a special character in your password. What was that special character and what was the exact command that you used?
You know that some special characters are also treated as special characters by the shell, so it is important how you escape those characters in the userpassword string and which quotation marks you use.

CMD shell in Linux is rather unusual. Perhaps you are using The Windows Subsystem for Linux (WSL)? Please add a screenshot with your command and its output.

@Daria_H

Please find the snap below.

and I tried with another password-
vWd4FL8123@11
vWd4,mQ+'m7;{FL8

@Daria_H
Can you please let me know what are the special characters are not allowed in password of hive-mq in shall CMD.

@mounika ,

Thanks for sharing your examples. So, if you want to add users:

  • mounika with password vWd4,mQ+'m7;{FL8
  • eva with password vWd4FL8123@11
  • jarek with password 8DF394857-GLKDJF48736-HFKJ3845673
  • robo with password pa$$word

First, Generate SHA256 Password:

#echo -n "mounikavWd4,mQ+'m7;{FL8" | shasum -a 256
5d4ec5e4ef68abf70717d0cba39f0aef3937e6d7ba963ae7e5e64411b3d4f650  -

#echo -n "evavWd4FL8123@11" | shasum -a 256
9f754c4c931bfba53d34265c9e5a5699729086b8051679c90feb0d823d8550e3  -

#echo -n "jarek8DF394857-GLKDJF48736-HFKJ3845673" | shasum -a 256
8c06beff1e094a678acb8865d54f745a634a229e9c5de0680936e775c2cbbec6  -

#echo -n "robopa\$\$word" | shasum -a 256
34b1c53070902b4d9cab862991427af67b80295ba3415114ef20293acf345a77  -

Second, configure users in the config.xml accordingly:

<?xml version="1.0"?>
<hivemq>

    <listeners>
        <tcp-listener>
            <port>1883</port>
            <bind-address>0.0.0.0</bind-address>
        </tcp-listener>
    </listeners>

    <anonymous-usage-statistics>
        <enabled>true</enabled>
    </anonymous-usage-statistics>

   <control-center>
        <enabled>true</enabled>
        <users>
            <user>
                <name>mounika</name>
                <password>5d4ec5e4ef68abf70717d0cba39f0aef3937e6d7ba963ae7e5e64411b3d4f650</password>
            </user>
            <user>
                <name>eva</name>
                <password>9f754c4c931bfba53d34265c9e5a5699729086b8051679c90feb0d823d8550e3</password>
            </user>
            <user>
                <name>jarek</name>
                <password>8c06beff1e094a678acb8865d54f745a634a229e9c5de0680936e775c2cbbec6</password>
            </user>
            <user>
                <name>robo</name>
                <password>34b1c53070902b4d9cab862991427af67b80295ba3415114ef20293acf345a77</password>
            </user>
        </users>
    </control-center>
</hivemq>

Third, start your HiveMQ broker. Go to https://localhost:8080 and log in with new users and passwords.

I hope this helps.

Regards,
Dasha from HiveMQ Team

Take a look here: Special Characters and Quoting - Learning the bash Shell, Second Edition [Book]

Hi! Using HiveMQ Control Center 4.22.0 - I have verified that the SHA hash for the password is correct, but when I add new users to the config.xml file I still cannot log in to the Control Center with these users. The error is “Wrong username or password”


I have checked the config file on the machines - it is deployed correctly and has these users/hashed passwords in the section.
What might be the problem here?

Hello @jsmith

Thank you for getting in touch. Could you kindly provide your config.xml file for review? Additionally, it would be appreciated if you could specify the exact command you used to generate the hash sum for the password. Moreover, please indicate the operating system (Windows, Linux, MacOS) and shell (bash, zsh, sh, cmd, PowerShell) in which the command was executed.

Regards,
Sheetal from the HiveMQ Team

Hi @jsmith

Regarding the special character you mentioned, could you please specify which special character is included in the password, and its position within the password string? This information will help us ensure that the hashing process is correctly accounting for any special characters and rule out potential issues related to their presence or placement.

For example, if your username is username and the password is password$123, the hash would be generated using:

echo -n 'usernamepassword$123' | shasum -a 256

Understanding the specifics of the special character will assist in troubleshooting and resolving the login issue.

Best regards,
Dasha from HiveMQ Team

This is a command I have been using for user3:
echo -n "=}k+ph@X}K4VeW5aaS" | shasum -a 256
The content of config.xml is below:

<?xml version="1.0"?>
<hivemq>
    <!-- <health-api>
        <enabled>true</enabled>
        <listeners>
            <http>
                <port>8889</port>
                <name>health-api-listener</name>
                <bind-address>127.0.0.1</bind-address>
            </http>
        </listeners>
    </health-api> -->
    <listeners>
        <tcp-listener>
            <port>1883</port>
            <bind-address>${PRIVATE_IP}</bind-address>
            <proxy-protocol>true</proxy-protocol>
        </tcp-listener>
        <tcp-listener>
            <port>8883</port>
            <bind-address>${PRIVATE_IP}</bind-address>
            <proxy-protocol>true</proxy-protocol>
        </tcp-listener>
    </listeners>
    <control-center>
        <listeners>
            <http>
                <port>8080</port>
                <bind-address>${PRIVATE_IP}</bind-address>
            </http>
            <!-- <http>
                <port>443</port>
                <bind-address>${PRIVATE_IP}</bind-address>
            </http> -->
            <!-- <http>
                <port>8443</port>
                <bind-address>${PRIVATE_IP}</bind-address>
            </http> -->
        </listeners>
        <users>
            <user>
                <name>user1</name>
                <password></password>
            </user>
            <user>
                <name>user2</name>
                <password></password>
            </user>
            <user>
                <name>user3</name>
                <password>806333a8d398193b06f9eb737b6758aba107dce148200df25b087d068039c3bc</password>
            </user>
        </users>
        <default-user-enabled>false</default-user-enabled>
    </control-center>
    <cluster>
        <enabled>true</enabled>
        <transport>
            <tcp>
                <bind-address>${PRIVATE_IP}</bind-address>
                <bind-port>7800</bind-port>
            </tcp>
        </transport>
        <discovery>
            <extension/>
        </discovery>
        <replication>
            <replica-count>2</replica-count>
        </replication>
    </cluster>
    <client-event-history>
        <enabled>true</enabled>
        <lifetime>604800</lifetime>        <!-- 7 days -->
    </client-event-history>
</hivemq>

Hello @jsmith

Thank you for providing additional details.

As mentioned by Dasha, the process involves creating a password hash using a combination of the username and password. The command you initially shared uses only the password, which is why it is encountering issues.

Kindly consider using the following command for generating the hash and then incorporate the hash into the HiveMQ config.xml file for user3:

#echo -n "user3=}k+ph@X}K4VeW5aaS" | shasum -a 256
1d385549b9b411420185127f8672a7652c6045c703c143671f469af47e34a830  -

Please retry the process with the updated command, and if you encounter any further challenges or have additional questions, feel free to reach out. We are here to assist you.

Regards,
Sheetal from HiveMQ Team

1 Like

Thank you, it worked!