How to change or reset a forgotten password?

Published on 10 October 2013 in Development - 3 minutes read - Last modified on 19 April 2021

Hue is the web interface that improves the Apache Hadoop user experience. It’s a Django driven application and manages users accordingly. In this tutorial, we’ll be exploring the different options available for altering passwords in Hue using the default authentication backend (AllowFirstUserBackend).

User Interface

Users can change their passwords via the “” -> “Edit Profile” found in the top-right corner of Hue.image

If a user cannot remember their password, the Hue administrator can change it for them via the user manager.image

If the Hue administrator loses their password, then a more technical approach must be taken.

Programmatic

When a Hue administrator loses their password, a more programmatic approach is required to secure the administrator again. Hue comes with a wrapper around the python interpreter called the “shell” command. It loads all the libraries required to work with Hue at a programmatic level. To start the Hue shell, type the following command from the Hue installation root.

If using CM, export this variable in order to point to the correct database:

HUE_CONF_DIR=/var/run/cloudera-scm-agent/process/-hue-HUE_SERVER-id

echo $HUE_CONF_DIR

export HUE_CONF_DIR

Where is the most recent ID in that process directory for hue-HUE_SERVER.

A quick way to get the correct directory is to use this script:

export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/\`ls -alrt /var/run/cloudera-scm-agent/process | grep HUE | tail -1 | awk '{print $9}'\`"

Then:

cd /usr/lib/hue (or /opt/cloudera/parcels/CDH-XXXXX/share/hue if using parcels and CM)

build/env/bin/hue shell

The following is a small script, that can be executed within the Hue shell, to change the password for a user named “example”:

from django.contrib.auth.models import User

user = User.objects.get(username='example')

user.set_password('some password')

user.save()

The script can also be invoked in the shell by using input redirection (assuming the script is in a file named script.py):

build/env/bin/hue shell < script.py

How to make a certain user a Hue admin

build/env/bin/hue shell

Then set these properties to true:

from django.contrib.auth.models import User

a = User.objects.get(username='hdfs')

a.is_staff = True

a.is_superuser = True

a.set_password('my_secret')

a.save()

How to change or reset a forgotten password?

Go on the Hue machine, then in the Hue home directory and either type:

To change the password of the currently logged in Unix user:

build/env/bin/hue changepassword

If you don’t remember the admin username, create a new Hue admin (you will then also be able to login and could change the password of another user in Hue):

build/env/bin/hue createsuperuser

 

Summary

We hope this helps you manage your password and assists administrators when they’ve lost their own passwords. In a future blog post, we will detail other ways to authenticate with Hue.

Have any suggestions? Feel free to tell us what you think through hue-user or at @gethue.


comments powered by Disqus

More recent stories

26 June 2024
Integrating Trino Editor in Hue: Supporting Data Mesh and SQL Federation
Read More
03 May 2023
Discover the power of Apache Ozone using the Hue File Browser
Read More