Monday, July 8, 2024

GreenBone GVM Community on KaliLinux admin password reset

 After trying all possible GVM command to get access to GUI after setup I found the only way how it worked for me. 

I have to change password directly on DB. Here are steps. And I tried to run this wihtout stopping service and it worked anyway. 

I;'m assuming that you know KALI terminal. You need 2 of them one for SQL and another for other things including HASH generation

Directly Resetting the Admin Password in PostgreSQL

  1. Stop the GVM services:

    sh

    sudo systemctl stop gvmd sudo systemctl stop ospd-openvas
  2. Access the PostgreSQL database: You need to access the gvmd database. The default user is usually postgres. Use the following command to access the PostgreSQL command line:

    sh

    sudo -u postgres psql gvmd
  3. List the users in the gvmd database:

    sql

    SELECT name FROM users;

    This will list all users. Identify the admin user.

  4. Reset the password: Replace admin_username with the actual username of your admin account, and newpassword with your desired password. Note that the password needs to be hashed.

    Generate a new password hash using gvmd command:


    sudo gvmd --user=admin_username --new-password=newpassword

    This should display a hash. If this does not work, you can generate the password hash using Python:

    python

    python3 -c "import crypt; print(crypt.crypt('newpassword', crypt.mksalt(crypt.METHOD_SHA512)))"
  5. Update the user's password in the PostgreSQL database:

    sql

    UPDATE users SET password='hashed_password' WHERE name='admin_username';
  6. Exit the PostgreSQL command line:

    sql

    \q
  7. Start the GVM services again:

    sh

    sudo systemctl start ospd-openvas sudo systemctl start gvmd
  8. Verify the Password Reset: Try logging into the GVM web interface with the new password to ensure the reset was successful.