# Reset admin password

**URL:** https://forum.yunohost.org/t/reset-admin-password/1681
**Category:** Support
**Tags:** english
**Created:** [June 22, 2016, 6:37pm UTC](https://forum.yunohost.org/t/reset-admin-password/1681 "2016-06-22T18:37:39Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [October 17, 2016, 3:34pm UTC](https://forum.yunohost.org/t/reset-admin-password/1681/13 "2016-10-17T15:34:05Z")

</div>

Hi guys,

thanks to this thread and discussion ! (I struggled with this issue many times now 😕 )

Based on the messages of @frog, @bastien and @jerome, I was able to write this small convenient script that allow to reset the admin password while being logged as root 🙂 .

(⚠ You might want to backup `/etc/ldap` before using this, just in case)

```auto
# Generate new password hash
NEW_PASSWORD_HASH=`slappasswd -h {SSHA}`

# Stop slapd service...
service slapd stop

# Backup slapd.conf (to be restored at the end of script)
cp /etc/ldap/slapd.conf /root/slapd.conf.bkp

# Append lines to slapd.conf to manually define root password hash
echo 'rootdn "cn=admin,dc=yunohost,dc=org"' >> /etc/ldap/slapd.conf
echo "rootpw $NEW_PASSWORD_HASH" >> /etc/ldap/slapd.conf

# Test conf (might not be entirely necessary though :P)
slaptest -Q -u -f /etc/ldap/slapd.conf 

# Regenerate slapd.d directory
rm -Rf /etc/ldap/slapd.d
mkdir /etc/ldap/slapd.d
slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d/ 2>&1

# Set permissions to slapd.d
chown -R openldap:openldap /etc/ldap/slapd.d/

# Restore slapd.conf
mv /root/slapd.conf.bkp /etc/ldap/slapd.conf

# Restart slapd service
service slapd start

```

---

_[View the full topic](https://forum.yunohost.org/t/reset-admin-password/1681)._
