---
title: How to change or reset a forgotten password?
author: admin
type: post
date: 2013-10-10T20:50:00+00:00
url: /password-management-in-hue/
tumblr_gethue_permalink:
- http://gethue.tumblr.com/post/63670895075/password-management-in-hue
tumblr_gethue_id:
- 63670895075
sf_thumbnail_type:
- none
sf_thumbnail_link_type:
- link_to_post
sf_detail_type:
- none
sf_page_title:
- 1
sf_page_title_style:
- standard
sf_no_breadcrumbs:
- 1
sf_page_title_bg:
- none
sf_page_title_text_style:
- light
sf_background_image_size:
- cover
sf_social_sharing:
- 1
sf_sidebar_config:
- left-sidebar
sf_left_sidebar:
- Sidebar-2
sf_right_sidebar:
- Sidebar-1
sf_caption_position:
- caption-right
slide_template:
- default
categories:
- Administration
- Development
---
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.
If a user cannot remember their password, the Hue administrator can change it for them via the user manager.
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:
{{< highlight bash >}}HUE_CONF_DIR=/var/run/cloudera-scm-agent/process/-hue-HUE_SERVER-id
echo $HUE_CONF_DIR
export HUE_CONF_DIR{{< /highlight >}}
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:
{{< highlight bash >}}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}'\`"{{< /highlight >}}
Then:
{{< highlight bash >}}cd /usr/lib/hue (or /opt/cloudera/parcels/CDH-XXXXX/share/hue if using parcels and CM)
build/env/bin/hue shell{{< /highlight >}}
The following is a small script, that can be executed within the Hue shell, to change the password for a user named “example”:
{{< highlight python >}}from django.contrib.auth.models import User
user = User.objects.get(username='example')
user.set_password('some password')
user.save()
{{< /highlight >}}
The script can also be invoked in the shell by using input redirection (assuming the script is in a file named script.py):
{{< highlight bash >}}build/env/bin/hue shell < script.py{{< /highlight >}}
# How to make a certain user a Hue admin
{{< highlight bash >}}build/env/bin/hue shell{{< /highlight >}}
Then set these properties to true:
{{< highlight python >}}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()
{{< /highlight >}}
# 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:
{{< highlight bash >}}build/env/bin/hue changepassword{{< /highlight >}}
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):
{{< highlight bash >}}build/env/bin/hue createsuperuser{{< /highlight >}}
# 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][1] or at [@gethue][2].
[1]: https://groups.google.com/a/cloudera.org/forum/?fromgroups#!forum/hue-user
[2]: https://twitter.com/gethue/