Added 3 additional scripts (refer to README.md for what they do)
- freeipa-samba-user.sh - freeipa-service-ntlm.sh - freeipa-service-password.sh
This commit is contained in:
138
README.md
138
README.md
@@ -10,11 +10,17 @@ between an existing situation and FreeIPA and are safe to run multiple times.
|
||||
As side-effect, this also makes them suitable to support a gradual migration
|
||||
over time (where a source system is still in production until final cut-over)
|
||||
|
||||
Please note that these scripts are intended to run on the FreeIPA server and
|
||||
require a valid (admin) kerberos ticket, which can be obtained with:
|
||||
```
|
||||
kinit admin
|
||||
```
|
||||
|
||||
The latest versions, documentation and a bug tracker are available on my
|
||||
[GitLab instance](https://gitlab.lindenaar.net/scripts/freeipa)
|
||||
|
||||
Copyright (c) 2018 Frederik Lindenaar. free for distribution under the GNU
|
||||
General Public License, see [below](#license)
|
||||
Copyright (c) 2018 - 2019 Frederik Lindenaar. free for distribution under the
|
||||
GNU General Public License, see [below](#license)
|
||||
|
||||
Contents
|
||||
========
|
||||
@@ -30,6 +36,12 @@ This repository contains the following scripts:
|
||||
around for bind-dyndb-ldap plugin not supporting bind's ```notify-source```
|
||||
* [users2freeipa.py](#users2freeipa)
|
||||
is a migration script to transfer/synchronize LDAP users to/with FreeIPA
|
||||
* [freeipa-service-password.sh](#freeipaservicepassword)
|
||||
is a script to create a service account and (re)set it's password
|
||||
* [freeipa-service-ntlm.sh](#freeipaservicentlm)
|
||||
is a script to grant a service account access to NTLM password attributes
|
||||
* [freeipa-samba-user.sh](freeipasambauser)
|
||||
is a script to extend users to a sambaSAMAccount for Samba compatibility
|
||||
|
||||
|
||||
<a name=freeipadns>freeipa-dns.py</a>
|
||||
@@ -133,7 +145,8 @@ This script will ensure the necessary setup is in place so that Certbot (EFF's
|
||||
certificate request script for Let's Encrypt) will work with FreeIPA for DNS
|
||||
challenges and and instructs it to deploy new certificates for FreeIPA's web
|
||||
interface. Before writing this script I looked at available options, especially
|
||||
[freeipa-letsencrypt](https://github.com/freeipa/freeipa-letsencrypt) and [antevens'](https://github.com/antevens/letsencrypt-freeipa) implementation but
|
||||
[freeipa-letsencrypt](https://github.com/freeipa/freeipa-letsencrypt) and
|
||||
[antevens'](https://github.com/antevens/letsencrypt-freeipa) implementation but
|
||||
decided to take a slightly different approach where Certbot does all the work
|
||||
and the setup script will only ensure that the environment is prepared and that
|
||||
Certbot is initially instructed correctly. This allows to fully tie-in with how
|
||||
@@ -160,7 +173,7 @@ by setting one of the following environment variables:
|
||||
|-------------|------------------------------------|---------------------------|
|
||||
| CERTNAME | certificate hostname, | host's canonicalname (1) |
|
||||
| DNSALTNAMES | certificate DNS names | host's principalnames (1) |
|
||||
| DOMAIN | Let's Encrypt challenge DNS zone | {DNS name's domain} (2) |
|
||||
| DOMAIN | Let's Encrypt challenge DNS zone | {DNS name's domain} (2) |
|
||||
| EMAIL | administrator's e-mail address | hostmaster@{domain} |
|
||||
| HOSTNAME | FreeIPA server's hostname | `hostname --fqdn` |
|
||||
| KEYTAB | Let'sEncrypt service's keytab file | /etc/letsencrypt/keytab |
|
||||
@@ -250,6 +263,123 @@ as FreeIPA does not yet support that) and use an ID View to store legacy data.
|
||||
For all available command-line options, run ```users2freeipa.py -h```
|
||||
|
||||
|
||||
<a name=freeipaservicepassword>freeipa-service-password.sh</a>
|
||||
--------------------------------------------------------------
|
||||
This script sets up a service under a host (creating both if needed) so that it
|
||||
can use an LDAP simple bind for authentication. Although it is straightforward
|
||||
to setup a host and service account in FreeIPA using the web interface, this
|
||||
will not allow it to perform an LDAP simple bind (without requiring Kerberos).
|
||||
For this, a direct change to the LDAP database is required to extend the service
|
||||
principal object and make it an ```simpleSecurityObject``` with a password. This
|
||||
script accepts a hostname and one or more services and should be run like:
|
||||
~~~
|
||||
./freeipa-service-password.sh <hostname> <service> [<service>]
|
||||
~~~
|
||||
|
||||
As it always sets the password this script can be used for initial setup as well
|
||||
as a reset of a service password. It performs the following actions:
|
||||
* Creates the host in FreeIPA (if it does not exists)
|
||||
When creating a new host it scans its SSH key and stores this in FreeIPA
|
||||
* Creates each service under the host in FreeIPA (if it does not exists)
|
||||
* (Re)sets each service’s LDAP password to a long generated random password
|
||||
|
||||
When done it prints the services bind DN and generated password for later use.
|
||||
|
||||
|
||||
<a name=freeipaservicentlm>freeipa-service-ntlm.sh</a>
|
||||
------------------------------------------------------
|
||||
This script grants a service under a host access to the LDAP attributes required
|
||||
to perform NLTM authentication. It sets up the necessary privilege, permission
|
||||
and a role to grant the rights (if necessary) and then assigns the role to the
|
||||
service on the host as specified on the command line. for this to work, Active
|
||||
Directory domain trust support must have been enabled with the command:
|
||||
~~~
|
||||
sudo ipa-adtrust-install --add-sid
|
||||
~~~
|
||||
(the ```--addsid``` parameter is required to convert existing users).
|
||||
|
||||
Please note that for the necessary attributes to become available, users *must*
|
||||
change their password after enabling Active Directoy domain support as FreeIPA
|
||||
only maintains the necessary attributes after the user object has been modified.
|
||||
|
||||
Running this command will make the ```ipNTHash``` attribute available with the
|
||||
necessary hash to perform NTLM authentication. Depending on whether the client
|
||||
implementation supports mapping the attribute it is sufficient to configure it
|
||||
to use this attribute or require to migrate users to the Samba schema with
|
||||
[freeipa-samba-user.sh](freeipasambauser). To use the script execute:
|
||||
~~~
|
||||
./freeipa-service-ntlm.sh <hostname> <service> [<service>]
|
||||
~~~
|
||||
The specified service principals must already exist (they can be created using
|
||||
[freeipa-service-password.sh](#freeipaservicepassword) or manually).
|
||||
|
||||
The script is built to auto-configure though some settings can be overridden by
|
||||
setting one of the following environment variables:
|
||||
|
||||
| Variable | Description | Default value |
|
||||
|-----------|-------------------------|----------------------------------------|
|
||||
| HOST | Service host hostname | 1st command line parameter |
|
||||
| HOSTNAME | FreeIPA server hostname | `hostname --fqdn` |
|
||||
| PERM_NAME | Name of permission | Read Samba NTLM RC4 Password Hash attribute |
|
||||
| PRIV_NAME | Name of privilege | Samba (NTLM) RC4 Password Hash Access |
|
||||
| ROLE_NAME | Name of role | Samba/NTLM Authenticator |
|
||||
|
||||
The description of the privilege / role creates can be changed through:
|
||||
| Variable | Default value |
|
||||
|----------------|-------------------------------------------------------------|
|
||||
|PRIV_DESCRIPTION|Perform Samba NTLM authentication using the RC4 password Hash|
|
||||
|ROLE_DESCRIPTION|Perform Samba (NTLM) Authentication using the RC4 Password hash|
|
||||
|
||||
|
||||
<a name=freeipasambauser>freeipa-samba-user.sh</a>
|
||||
--------------------------------------------------
|
||||
This script adds the ```sambaSAMAccount``` objectclass to specified users so
|
||||
that they can with Samba / NTLM. For everything to work, the Samba server must
|
||||
login with a service account that has a simple password (setup with
|
||||
[freeipa-service-password.sh](#freeipaservicepassword)) with access to the NTLM
|
||||
password attributes (setup with [freeipa-service-ntlm.sh](#freeipaservicentlm)).
|
||||
This script was written to support integration with Synology DSM (see also this
|
||||
[blog post](https://frederik.lindenaar.nl/2019/07/14/integrating-synology-ds-with-freeipa.html))
|
||||
but should also work for other Samba servers (please raise an issue in case it
|
||||
doesn't work). I found that FreeIPA will maintain and expose required attributes
|
||||
for NTLM authentication (```sambaNTPassword``` and ```sambaPwdLastSet```) when
|
||||
Active Directory domain trust support has been enabled with the command:
|
||||
~~~
|
||||
sudo ipa-adtrust-install --add-sid
|
||||
~~~
|
||||
(the ```--addsid``` parameter is required to convert existing users).
|
||||
|
||||
To use the script to migrate all users (except admin) run (the backslash is
|
||||
needed to avoid shell expansion of * as parameter):
|
||||
~~~
|
||||
./freeipa-service-password.sh \*
|
||||
~~~
|
||||
|
||||
Besides a single * the script also accepts the login of one or more users to
|
||||
migrate as parameter. To explicitly migrate admin - excluded with * - run:
|
||||
~~~
|
||||
./freeipa-samba-user.sh admin
|
||||
~~~
|
||||
|
||||
The script will only migrate users that are not yet a ```sambaSAMAccount``` so
|
||||
it can be run safely multiple times or at set intervals from cron (additional
|
||||
work is required to make that work though as it will need a valid Kerberos
|
||||
ticket from a keytab file for that).
|
||||
|
||||
Please note that for the necessary attributes to become available, users *must*
|
||||
change their password after being converted ```sambaSAMAccount``` as FreeIPA
|
||||
only maintains the necessary attributes after the user object has been modified.
|
||||
|
||||
The script is built to auto-configure though some settings can be overridden by
|
||||
setting one of the following environment variables:
|
||||
|
||||
| Variable | Description | Default value |
|
||||
|-------------|------------------------------------|---------------------------|
|
||||
| HOST | Service host hostname | 1st command line parameter|
|
||||
| HOSTNAME | FreeIPA server's hostname | `hostname --fqdn` |
|
||||
| SAMBADOMAIN | Samba (Windows) domain name | FreeIPA Kerberos realm |
|
||||
|
||||
|
||||
<a name="license">License</a>
|
||||
-----------------------------
|
||||
These scripts, documentation & configration examples are free software: you can
|
||||
|
||||
Reference in New Issue
Block a user