Ad Widget

Collapse

Reset Admin Password for Zabbix LTS 5.0

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TiddleMiddle
    Junior Member
    • Nov 2019
    • 5

    #1

    Reset Admin Password for Zabbix LTS 5.0

    I have tried to reset the root Admin password for our Zabbix 5.0 LTS server using postgresql, but the password hashing algorithm has changed and has invalidated the old instructions (Im sure more has changed in how users are handled in the db).

    Anyone know the newer method for the current version?
  • Answer selected by dimir at 09-11-2021, 16:30.
    dimir
    Zabbix developer
    • Apr 2011
    • 1080

    Since 5.0 Zabbix switched from md5 hashing algorithm to bcrypt: https://support.zabbix.com/browse/ZBXNEXT-1898
    Since then, on the first log in after upgrade all md5 hashes are converted to bcrypt by Frontend automatically.

    If you want to reset your password the easiest would be to first generate the hash. If you have package apache2-utils installed (that's on a Debian-based distros, RedHat-based would be httpd-tools), use htpasswd and then go to the database and set it:
    Code:
    htpasswd -bnBC 10 "" YourNewPassword | tr -d ':'
    
    <copy the output>
    
    mysql ...
    ]> update users set passwd='<copied output>' where alias='Admin';
    Query OK, 0 rows affected (0.001 sec)
    Rows matched: 1 Changed: 0 Warnings: 0
    Last edited by dimir; 08-10-2020, 16:13.

    Comment

    • dimir
      Zabbix developer
      • Apr 2011
      • 1080

      #2
      Since 5.0 Zabbix switched from md5 hashing algorithm to bcrypt: https://support.zabbix.com/browse/ZBXNEXT-1898
      Since then, on the first log in after upgrade all md5 hashes are converted to bcrypt by Frontend automatically.

      If you want to reset your password the easiest would be to first generate the hash. If you have package apache2-utils installed (that's on a Debian-based distros, RedHat-based would be httpd-tools), use htpasswd and then go to the database and set it:
      Code:
      htpasswd -bnBC 10 "" YourNewPassword | tr -d ':'
      
      <copy the output>
      
      mysql ...
      ]> update users set passwd='<copied output>' where alias='Admin';
      Query OK, 0 rows affected (0.001 sec)
      Rows matched: 1 Changed: 0 Warnings: 0
      Last edited by dimir; 08-10-2020, 16:13.

      Comment

      • TiddleMiddle
        Junior Member
        • Nov 2019
        • 5

        #3
        Originally posted by dimir
        Since 5.0 Zabbix switched from md5 hashing algorithm to bcrypt: https://support.zabbix.com/browse/ZBXNEXT-1898
        Since then, on the first log in after upgrade all md5 hashes are converted to bcrypt by Frontend automatically.

        If you want to reset your password the easiest would be to first generate the hash. If you have package apache2-utils installed (that's on a Debian-based distros, RedHat-based would be httpd-tools), use htpasswd and then go to the database and set it:
        Code:
        htpasswd -bnBC 10 "" YourNewPassword | tr -d ':'
        
        <copy the output>
        
        mysql ...
        ]> update users set passwd='<copied output>' where alias='Admin';
        Query OK, 0 rows affected (0.001 sec)
        Rows matched: 1 Changed: 0 Warnings: 0
        Long story short, I was reviving a database that got mangled after a poorly prepared and thought out disk shrinkage.

        I was able to recover the database but was locked out. For some reason there was no Admin account (?), but I was able to reset my old account and get into the server using this method.

        Thank you very much!

        Comment

        • Gutsycat
          Member
          • Nov 2017
          • 72

          #4
          Get standard username/password from create.sql.gz

          Code:
          INSERT INTO `users` (`userid`,`alias`,`name`,`surname`,`passwd`,`url`, `autologin`,`autologout`,`lang`,`refresh`,`type`,` theme`,`rows_per_page`) values ('1','Admin','Zabbix','Administrator','$2y$10$92nDno4n0Zm7Ej7Jfsz8WukBfgSS/U0QkIuu8WkJPihXBb2A1UrEK','','1','0','en_GB','30s' ,'3','default','50');
          INSERT INTO `users` (`userid`,`alias`,`name`,`surname`,`passwd`,`url`, `autologin`,`autologout`,`lang`,`refresh`,`type`,` theme`,`rows_per_page`) values ('2','guest','','','$2y$10$89otZrRNmde97rIyzclecuk6LwKAsHN0BcvoOKGjbT.BwMBfm7G06','','0','15m','en_G B','30s','1','default','50');
          Last edited by Gutsycat; 12-10-2020, 07:50.

          Comment

          • dimir
            Zabbix developer
            • Apr 2011
            • 1080

            #5
            Good point, Gutsycat!

            Comment

            • sur1ya
              Junior Member
              • Jul 2021
              • 3

              #6
              Has the above problem been resolved?
              I am having the same problem.

              However, I tried updating the htpasswd method and the passwd of the initial default setting create.sql, but still
              I can't log in as Admin/zabbix...

              Can you please let me know if I am doing something wrong?

              htpasswd -bnBC 10 "" YourNewPassword | tr -d ':'
              To set the password of the password to 'zabbix' in this division

              htpasswd -bnBC 10 "zabbix" YourNewPassword | tr -d ':'
              do i have to do this?

              Comment

              • JustTheGuyNatan
                Junior Member
                • Sep 2022
                • 5

                #7
                I don't understand why I am not authorized to change my own posts, but the post above was flawed by my own mistake. It indeed does work for me on zabbix 6.2.2.
                The mistake I made was rather foolish but since others might do the same: I accidentally created the hash, inserted it into the database and then tried to login using the hash as the password - which is obviously wrong.

                If someone knows a way how to create the hash directly in SQL (or Ansible; since I am using that to setup zabbix), please share it.

                Comment

                Working...