> For the complete documentation index, see [llms.txt](https://thorstenkramm.gitbook.io/saltstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thorstenkramm.gitbook.io/saltstack/salt-states/beispiel-benutzer-verwalten.md).

# Beispiel Benutzer verwalten

zentrale Benutzerverwaltung über Salt

### Simpel

{% code title="/srv/salt/users/www-data.sls" %}

```yaml
caddy:
  group.present: []
  user.present:
    - fullname: Webserver
    - shell: /usr/sbin/nologin
    - home: /var/www
    - createhome: true
    - system: true
    - groups:
        - caddy
```

{% endcode %}

{% hint style="success" %}
Es ist möglich, mehrer State-Module unterhalb einer gemeinsamen Sate-ID zusammenzufassen.
{% endhint %}

### Vollständig

{% code title="/srv/salt/users/thorsten.sls" %}

```yaml
#
# Make sure the user is present
#
thorsten:
  group.present: []
  user.present:
    - fullname: Thorsten Kramm
    - shell: /bin/bash
    - home: /home/thorsten
    - createhome: true
    - system: false
    - groups:
      - thorsten

#
# Deploy the public SSH Key of the user
#
thorstens-key:
  ssh_auth.present:
    - user: thorsten
    - source: salt://users/ssh_keys/thorsten.id_rsa.pub

#
# Make sure the user can use sudo without a password
#
sudo:
  pkg.installed: []

/etc/sudoers.d/thorsten:
  file.managed:
    - contents: thorsten ALL=(ALL) NOPASSWD:ALL
```

{% endcode %}

{% hint style="warning" %}
Dateien im Ordner `/etc/sudoers.d` dürfen keinen Punkt im Dateinamen enthalten.&#x20;
{% endhint %}
