This commit is contained in:
Zhang Huangbin 2021-09-08 19:13:12 +08:00
parent 9b2bed92b5
commit b2ff1e512f
2 changed files with 81 additions and 99 deletions

View File

@ -2,6 +2,51 @@
[TOC]
## Reset password with scripts shipped in iRedAdmin(-Pro)
### Reset password for one user
iRedAdmin(-Pro) ships script `tools/reset_user_password.py` to help you reset
one user's password. For example, on CentOS 7 (iRedAdmin is installed under
`/opt/www/iredadmin`):
```
cd /opt/www/iredadmin/tools/
python3 reset_user_password.py user@domain.ltd '123456'
```
Sample output:
```
[user@domain.ltd] Password has been reset.
```
### Reset passwords for multiple users with a CSV file
If you need to update many users' passwords, another way is resetting passwords
with script shipped in iRedAdmin-Pro: `tools/update_password_in_csv.py`. It
reads the user email addresses and NEW passwords from a CSV file.
The content is CSV file is:
```
<email> <new_password>
```
One mail user (and new password) per line. For example, file `new_passwords.csv`:
```
user1@domain.com pF4mTq4jaRzDLlWl
user2@domain.com SPhkTUlZs1TBxvmJ
user3@domain.com 8deNR8IBLycRujDN
```
Then run script with this file:
```
python3 update_password_in_csv.py new_passwords.csv
```
## Reset password with SQL/LDAP command line
### Generate password hash for new password
@ -50,60 +95,6 @@ LDAP client tools. `SSHA512` is recommended, but if you have some application
which needs to perform authentication with ldap dn directly, then `SSHA` is
preferred.
## Reset password with scripts shipped in iRedAdmin-Pro
!!! attention
iRedAdmin-Pro scripts support both SQL and LDAP backends.
### Reset password for one user
iRedAdmin-Pro ships script `tools/reset_user_password.py` to help you reset
one user's password. For example, on CentOS 7 (iRedAdmin is installed under
`/opt/www/iredadmin`):
!!! attention
You can find the iRedAdmin-Pro installation directory from this tutorial:
[Locations of configuration and log files of major components](./file.locations.html#iredadmin).
```
cd /opt/www/iredadmin/tools/
python reset_user_password.py user@domain.ltd '123456'
```
Sample output:
```
[user@domain.ltd] Password has been reset.
```
### Reset passwords for multiple users with a CSV file
If you need to update many users' passwords, another way is resetting passwords
with script shipped in iRedAdmin-Pro: `tools/update_password_in_csv.py`. It
reads the user email addresses and NEW passwords from a CSV file.
The content is CSV file is:
```
<email> <new_password>
```
One mail user (and new password) per line. For example, file `new_passwords.csv`:
```
user1@domain.com pF4mTq4jaRzDLlWl
user2@domain.com SPhkTUlZs1TBxvmJ
user3@domain.com 8deNR8IBLycRujDN
```
Then run script with this file:
```
python update_password_in_csv.py new_passwords.csv
```
## See also
* [Password hashes used/supported by iRedMail](./password.hashes.html)

View File

@ -23,22 +23,53 @@
<div class="toc">
<ul>
<li><a href="#reset-user-password">Reset user password</a><ul>
<li><a href="#reset-password-with-scripts-shipped-in-iredadmin-pro">Reset password with scripts shipped in iRedAdmin(-Pro)</a><ul>
<li><a href="#reset-password-for-one-user">Reset password for one user</a></li>
<li><a href="#reset-passwords-for-multiple-users-with-a-csv-file">Reset passwords for multiple users with a CSV file</a></li>
</ul>
</li>
<li><a href="#reset-password-with-sqlldap-command-line">Reset password with SQL/LDAP command line</a><ul>
<li><a href="#generate-password-hash-for-new-password">Generate password hash for new password</a></li>
<li><a href="#sql-backends">SQL backends</a></li>
<li><a href="#ldap-backends">LDAP backends</a></li>
</ul>
</li>
<li><a href="#reset-password-with-scripts-shipped-in-iredadmin-pro">Reset password with scripts shipped in iRedAdmin-Pro</a><ul>
<li><a href="#reset-password-for-one-user">Reset password for one user</a></li>
<li><a href="#reset-passwords-for-multiple-users-with-a-csv-file">Reset passwords for multiple users with a CSV file</a></li>
</ul>
</li>
<li><a href="#see-also">See also</a></li>
</ul>
</li>
</ul>
</div>
<h2 id="reset-password-with-scripts-shipped-in-iredadmin-pro">Reset password with scripts shipped in iRedAdmin(-Pro)</h2>
<h3 id="reset-password-for-one-user">Reset password for one user</h3>
<p>iRedAdmin(-Pro) ships script <code>tools/reset_user_password.py</code> to help you reset
one user's password. For example, on CentOS 7 (iRedAdmin is installed under
<code>/opt/www/iredadmin</code>):</p>
<pre><code>cd /opt/www/iredadmin/tools/
python3 reset_user_password.py user@domain.ltd '123456'
</code></pre>
<p>Sample output:</p>
<pre><code>[user@domain.ltd] Password has been reset.
</code></pre>
<h3 id="reset-passwords-for-multiple-users-with-a-csv-file">Reset passwords for multiple users with a CSV file</h3>
<p>If you need to update many users' passwords, another way is resetting passwords
with script shipped in iRedAdmin-Pro: <code>tools/update_password_in_csv.py</code>. It
reads the user email addresses and NEW passwords from a CSV file.</p>
<p>The content is CSV file is:</p>
<pre><code>&lt;email&gt; &lt;new_password&gt;
</code></pre>
<p>One mail user (and new password) per line. For example, file <code>new_passwords.csv</code>:</p>
<pre><code>user1@domain.com pF4mTq4jaRzDLlWl
user2@domain.com SPhkTUlZs1TBxvmJ
user3@domain.com 8deNR8IBLycRujDN
</code></pre>
<p>Then run script with this file:</p>
<pre><code>python3 update_password_in_csv.py new_passwords.csv
</code></pre>
<h2 id="reset-password-with-sqlldap-command-line">Reset password with SQL/LDAP command line</h2>
<h3 id="generate-password-hash-for-new-password">Generate password hash for new password</h3>
<p>Storing password in plain text is dangerous, so we need to hash the password.
@ -81,46 +112,6 @@ sql&gt; UPDATE mailbox SET password='{SSHA512}jOcGSlKEz95VeuLGecbL0MwJKy0yWY9foj
LDAP client tools. <code>SSHA512</code> is recommended, but if you have some application
which needs to perform authentication with ldap dn directly, then <code>SSHA</code> is
preferred.</p>
<h2 id="reset-password-with-scripts-shipped-in-iredadmin-pro">Reset password with scripts shipped in iRedAdmin-Pro</h2>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<p>iRedAdmin-Pro scripts support both SQL and LDAP backends.</p>
</div>
<h3 id="reset-password-for-one-user">Reset password for one user</h3>
<p>iRedAdmin-Pro ships script <code>tools/reset_user_password.py</code> to help you reset
one user's password. For example, on CentOS 7 (iRedAdmin is installed under
<code>/opt/www/iredadmin</code>):</p>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<p>You can find the iRedAdmin-Pro installation directory from this tutorial:
<a href="./file.locations.html#iredadmin">Locations of configuration and log files of major components</a>.</p>
</div>
<pre><code>cd /opt/www/iredadmin/tools/
python reset_user_password.py user@domain.ltd '123456'
</code></pre>
<p>Sample output:</p>
<pre><code>[user@domain.ltd] Password has been reset.
</code></pre>
<h3 id="reset-passwords-for-multiple-users-with-a-csv-file">Reset passwords for multiple users with a CSV file</h3>
<p>If you need to update many users' passwords, another way is resetting passwords
with script shipped in iRedAdmin-Pro: <code>tools/update_password_in_csv.py</code>. It
reads the user email addresses and NEW passwords from a CSV file.</p>
<p>The content is CSV file is:</p>
<pre><code>&lt;email&gt; &lt;new_password&gt;
</code></pre>
<p>One mail user (and new password) per line. For example, file <code>new_passwords.csv</code>:</p>
<pre><code>user1@domain.com pF4mTq4jaRzDLlWl
user2@domain.com SPhkTUlZs1TBxvmJ
user3@domain.com 8deNR8IBLycRujDN
</code></pre>
<p>Then run script with this file:</p>
<pre><code>python update_password_in_csv.py new_passwords.csv
</code></pre>
<h2 id="see-also">See also</h2>
<ul>
<li><a href="./password.hashes.html">Password hashes used/supported by iRedMail</a></li>