{"id":419256,"date":"2025-02-03T09:10:30","date_gmt":"2025-02-03T09:10:30","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=419256"},"modified":"2025-02-03T09:10:30","modified_gmt":"2025-02-03T09:10:30","slug":"erstellung-neuer-admin-benutzer-unter-linux-automatisieren","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/erstellung-neuer-admin-benutzer-unter-linux-automatisieren\/","title":{"rendered":"Kompletter Skript-Guide: Automatisierte Erstellung neuer Admin-Benutzer unter Linux"},"content":{"rendered":"<h2>Die wichtigsten Erkenntnisse<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Man kann die Erstellung neuer Admin-Benutzer unter Linux automatisieren:<\/strong> Optimiert den Prozess des Hinzuf\u00fcgens neuer Admin-Benutzer in Linux-Umgebungen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Erh\u00f6ht Effizienz und Genauigkeit:<\/strong> Reduziert den manuellen Aufwand und minimiert das Risiko menschlichen Versagens.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Skript-Flexibilit\u00e4t:<\/strong> Anpassbar an verschiedene Bed\u00fcrfnisse, mit Unterst\u00fctzung unterschiedlicher Benutzer-, Passwort- und Gruppenoptionen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Sicherheit im Mittelpunkt:<\/strong> Enth\u00e4lt Passwortverschl\u00fcsselung und erfordert Root-Rechte, um die Sicherheit zu erh\u00f6hen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Vielseitig einsetzbar:<\/strong> Geeignet sowohl f\u00fcr Einzelpersonen als auch f\u00fcr MSP, die mehrere Linux-Systeme verwalten.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Vergleich mit traditionellen Methoden:<\/strong> Bietet im Vergleich zu manuellen Befehlen oder GUI-Tools eine koh\u00e4rentere und skalierbarere L\u00f6sung.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>H\u00e4ufig gestellte Fragen:<\/strong> Beantwortet Fragen zur Sicherheit, Kompatibilit\u00e4t und zum Massenbetrieb.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\"><strong>Auswirkungen auf Sicherheit:<\/strong> Betont die Bedeutung einer angemessenen Verwaltung von Berechtigungen und der \u00dcberpr\u00fcfung der Skriptverwendung.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\"><strong>Best Practices:<\/strong> Tests, Protokollierung und regelm\u00e4\u00dfige \u00dcberpr\u00fcfung der Konten wird empfohlen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"10\" data-aria-level=\"1\"><strong>Integration in NinjaOne:<\/strong> Solche Skripte erg\u00e4nzen umfassendere IT-Management-Plattformen wie NinjaOne.<\/li>\n<\/ul>\n<p>Die effektive Verwaltung von Linux-Systemen erfordert h\u00e4ufig die Erstellung und Verwaltung von Benutzerkonten, insbesondere von solchen mit Administratorrechten. F\u00fcr Systemadministrator:innen und IT-Expert:innen ist es wichtig, die Feinheiten dieses Prozesses zu verstehen. Das heute vorgestellte Skript erf\u00fcllt diese Anforderung, indem es eine effiziente Methode zum Hinzuf\u00fcgen neuer Administrator:innen in Linux-Umgebungen bietet.<\/p>\n<h2>Kontext<\/h2>\n<p>In der Welt der IT ist die Verwaltung von Benutzerkonten eine grundlegende Aufgabe. Dieses Skript ist besonders f\u00fcr IT-Expert:innen und <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\" target=\"_blank\" rel=\"noopener\">Managed Service Provider (MSPs)<\/a> relevant, die h\u00e4ufig mit mehreren Linux-Servern oder -Workstations arbeiten. Dass man die Erstellung von Admin-Benutzern unter Linux automatisieren kann, spart nicht nur Zeit, sondern verringert auch die Wahrscheinlichkeit menschlichen Versagens. Ihre Bedeutung kann in Szenarien, in denen eine schnelle und sichere Benutzerverwaltung entscheidend ist, nicht untersch\u00e4tzt werden.<\/p>\n<h2>Das Skript<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Create a new admin user for Linux, by adding the user to the sudo group.\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n\r\n# Usage: [-u|--user &lt;arg&gt;] [-p|--pass &lt;arg&gt;] [-g|--group &lt;arg&gt;] [-d|--disable &lt;arg&gt;] [-h|--help]\r\n# -u, --user: User Name for new user account. (no default)\r\n# -p, --pass: Password for new user account. (no default)\r\n# -g, --group: Name of group to add the new user account to. (default 'sudo')\r\n# -d, --disable: Date to disable account. (no default)\r\n# -h, --help: Prints help\r\n\r\n# # When called, the process ends.\r\n# Args:\r\n# \t$1: The exit message (print to stderr)\r\n# \t$2: The exit code (default is 1)\r\n# if env var _PRINT_HELP is set to 'yes', the usage is print to stderr (prior to $1)\r\n# Example:\r\n# \ttest -f \"$_arg_infile\" || _PRINT_HELP=yes die \"Can't continue, have to supply file as an argument, got '$_arg_infile'\" 4\r\ndie() {\r\n    local _ret=\"${2:-1}\"\r\n    test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n    echo \"$1\" &gt;&amp;2\r\n    exit \"${_ret}\"\r\n}\r\n\r\n# Function that evaluates whether a value passed to it begins by a character\r\n# that is a short option of an argument the script knows about.\r\n# This is required in order to support getopts-like short options grouping.\r\nbegins_with_short_option() {\r\n    local first_option all_short_options='uph'\r\n    first_option=\"${1:0:1}\"\r\n    test \"$all_short_options\" = \"${all_short_options\/$first_option\/}\" &amp;&amp; return 1 || return 0\r\n}\r\n_arg_user=\r\n_arg_pass=\r\n_arg_group=\"sudo\"\r\n_arg_disable=\r\n\r\nif [[ -n \"${username}\" ]]; then\r\n    _arg_user=$username\r\nfi\r\nif [[ -n \"${password}\" ]]; then\r\n    _arg_pass=$password\r\nfi\r\nif [[ -n \"${group}\" ]] &amp;&amp; [[ \"${group}\" != \"null\" ]]; then\r\n    _arg_group=$group\r\nfi\r\nif [[ -n \"${disableAfterDate}\" ]] &amp;&amp; [[ \"${disableAfterDate}\" != \"null\" ]]; then\r\n    _arg_disable=$(date -d \"$disableAfterDate\" +'%Y-%m-%d')\r\nfi\r\n\r\n# Function that prints general usage of the script.\r\n# This is useful if users asks for it, or if there is an argument parsing error (unexpected \/ spurious arguments)\r\n# and it makes sense to remind the user how the script is supposed to be called.\r\nprint_help() {\r\n    printf '%s\\n' \"Create a new admin user.\"\r\n    printf 'Usage: %s [-u|--user &lt;arg&gt;] [-p|--pass &lt;arg&gt;] [-g|--group &lt;arg&gt;] [-e|--enable &lt;arg&gt;] [-d|--disable &lt;arg&gt;] [-h|--help]\\n' \"$0\"\r\n    printf '\\t%s\\n' \"-u, --user: User Name for new user account. (no default)\"\r\n    printf '\\t%s\\n' \"-p, --pass: Password for new user account. (no default)\"\r\n    printf '\\t%s\\n' \"-g, --group: Name of group to add the new user account to. (default 'sudo')\"\r\n    printf '\\t%s\\n' \"-d, --disable: Date to disable account. (no default)\"\r\n    printf '\\t%s\\n' \"-h, --help: Prints help\"\r\n}\r\n\r\n# The parsing of the command-line\r\nparse_commandline() {\r\n    while test $# -gt 0; do\r\n        _key=\"$1\"\r\n        case \"$_key\" in\r\n        # We support whitespace as a delimiter between option argument and its value.\r\n        # Therefore, we expect the --user or -u value.\r\n        # so we watch for --user and -u.\r\n        # Since we know that we got the long or short option,\r\n        # we just reach out for the next argument to get the value.\r\n        -u | --user)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_user=\"$2\"\r\n            shift\r\n            ;;\r\n        # We support the = as a delimiter between option argument and its value.\r\n        # Therefore, we expect --user=value, so we watch for --user=*\r\n        # For whatever we get, we strip '--user=' using the ${var##--user=} notation\r\n        # to get the argument value\r\n        --user=*)\r\n            _arg_user=\"${_key##--user=}\"\r\n            ;;\r\n        # We support getopts-style short arguments grouping,\r\n        # so as -u accepts value, we allow it to be appended to it, so we watch for -u*\r\n        # and we strip the leading -u from the argument string using the ${var##-u} notation.\r\n        -u*)\r\n            _arg_user=\"${_key##-u}\"\r\n            ;;\r\n        # See the comment of option '--user' to see what's going on here - principle is the same.\r\n        -p | --pass)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_pass=\"$2\"\r\n            shift\r\n            ;;\r\n        # See the comment of option '--user=' to see what's going on here - principle is the same.\r\n        --pass=*)\r\n            _arg_pass=\"${_key##--pass=}\"\r\n            ;;\r\n        # See the comment of option '-u' to see what's going on here - principle is the same.\r\n        -p*)\r\n            _arg_pass=\"${_key##-p}\"\r\n            ;;\r\n        # See the comment of option '--user' to see what's going on here - principle is the same.\r\n        -g | --group)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_group=\"$2\"\r\n            shift\r\n            ;;\r\n        # See the comment of option '--user=' to see what's going on here - principle is the same.\r\n        --group=*)\r\n            _arg_group=\"${_key##--group=}\"\r\n            ;;\r\n        # See the comment of option '-u' to see what's going on here - principle is the same.\r\n        -g*)\r\n            _arg_group=\"${_key##-g}\"\r\n            ;;\r\n        # See the comment of option '--user' to see what's going on here - principle is the same.\r\n        -d | --disable)\r\n            test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n            _arg_disable=\"$2\"\r\n            shift\r\n            ;;\r\n        # See the comment of option '--user=' to see what's going on here - principle is the same.\r\n        --disable=*)\r\n            _arg_disable=\"${_key##--disable=}\"\r\n            ;;\r\n        # See the comment of option '-u' to see what's going on here - principle is the same.\r\n        -d*)\r\n            _arg_disable=\"${_key##-d}\"\r\n            ;;\r\n        # The help argument doesn't accept a value,\r\n        # we expect the --help or -h, so we watch for them.\r\n        -h | --help)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        # We support getopts-style short arguments clustering,\r\n        # so as -h doesn't accept value, other short options may be appended to it, so we watch for -h*.\r\n        # After stripping the leading -h from the argument, we have to make sure\r\n        # that the first character that follows corresponds to a short option.\r\n        -h*)\r\n            print_help\r\n            exit 0\r\n            ;;\r\n        *)\r\n            _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n            ;;\r\n        esac\r\n        shift\r\n    done\r\n}\r\n\r\nparse_commandline \"$@\"\r\n\r\nif [[ -z \"${_arg_user}\" ]]; then\r\n    die \"FATAL ERROR: User Name is required. '$_arg_user'\" 1\r\nfi\r\n\r\nif [[ -z \"${_arg_pass}\" ]]; then\r\n    die \"FATAL ERROR: Password is required. '$_arg_pass'\" 1\r\nfi\r\n\r\nif [ \"$(id -u)\" -eq 0 ]; then\r\n    if grep -E \"^$_arg_user\" \/etc\/passwd &gt;\/dev\/null; then\r\n        # User already exists, add them to the group\r\n        echo \"$_arg_user exists!\"\r\n        if usermod -aG \"$_arg_group\" \"$_arg_user\"; then\r\n            echo \"User($_arg_user) has been added to $_arg_group group!\"\r\n        else\r\n            echo \"Failed to add a user to $_arg_group group!\"\r\n            exit 1\r\n        fi\r\n    else\r\n        pass=$(perl -e 'print crypt($ARGV[0], \"password\")' \"$_arg_pass\")\r\n        if useradd -m -p \"$pass\" \"$_arg_user\"; then\r\n            echo \"User($_arg_user) has been added to system!\"\r\n        else\r\n            echo \"Failed to add a user!\"\r\n            exit 1\r\n        fi\r\n        if usermod -aG \"$_arg_group\" \"$_arg_user\"; then\r\n            echo \"User($_arg_user) has been added to $_arg_group group!\"\r\n        else\r\n            echo \"Failed to add a user to $_arg_group group!\"\r\n            exit 1\r\n        fi\r\n    fi\r\n    if [[ -n \"${_arg_disable}\" ]]; then\r\n        # Expire the user after date\r\n        usermod -e \"$_arg_disable\" \"$_arg_user\"\r\n    fi\r\n\r\nelse\r\n    echo \"Only root may add a user to the system.\"\r\n    exit 2\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p style=\"text-align: center;\">Greifen Sie auf \u00fcber 300 Skripte im NinjaOne Dojo zu.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detaillierte Aufschl\u00fcsselung<\/h2>\n<h3>Skript-Funktionalit\u00e4t:<\/h3>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Einrichtung der Umgebung:<\/strong> Das Skript beginnt mit einer Shebang-Zeile <strong>#!\/usr\/bin\/env bash<\/strong>, die die Umgebung f\u00fcr die Verwendung von Bash als Skriptsprache einrichtet.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Beschreibung und Verwendung:<\/strong> Es enth\u00e4lt Kommentare, die seinen Zweck erkl\u00e4ren: Einen neuen Administrator-Benutzer zu erstellen, indem er ihn einer Gruppe hinzuf\u00fcgt, typischerweise &#8217;sudo&#8216;.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Funktionsdefinitionen:<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>die()<\/strong>: Behandelt Exit-Szenarien und zeigt bei Bedarf Fehlermeldungen an.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>begins_with_short_option()<\/strong>: Hilft beim Parsen von Befehlszeilenoptionen. \\<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>print_help()<\/strong>: Zeigt die Benutzungsanweisungen an.<\/li>\n<\/ul>\n<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Initialisierung der Variablen:<\/strong> Variablen wie <strong>_arg_user<\/strong>, <strong>_arg_pass<\/strong>, <strong>_arg_group<\/strong> und <strong>_arg_disable<\/strong> werden initialisiert.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Parsen von Befehlszeilenargumenten:<\/strong> Die Funktion <strong>parse_commandline()<\/strong> iteriert \u00fcber die Argumente, um Benutzer, Passwort, Gruppe und Deaktivierungsdatum festzulegen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Logik der Benutzererstellung:<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Pr\u00fcft, ob der Benutzer existiert.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Wenn nicht, wird ein neuer Benutzer erstellt und der angegebenen Gruppe hinzugef\u00fcgt.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Legt optional ein Deaktivierungsdatum f\u00fcr das Benutzerkonto fest.<\/li>\n<\/ul>\n<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>\u00dcberpr\u00fcfung der Root-Rechte:<\/strong> Stellt sicher, dass das Skript von einem Benutzer mit Root-Rechten ausgef\u00fchrt wird, ein notwendiger Schritt zum Erstellen und \u00c4ndern von Benutzerkonten.<\/li>\n<\/ul>\n<h2>M\u00f6gliche Anwendungsf\u00e4lle<\/h2>\n<p>Nehmen wir an, ein MSP verwaltet eine Vielfalt von Linux-Servern f\u00fcr einen Kunden. Er erh\u00e4lt eine Anfrage zur schnellen Einbindung eines neuen Entwickler-Teams, das Administratorrechte ben\u00f6tigt. Mit diesem Skript kann der MSP auf effiziente Weise individuelle Administratorkonten einrichten und so sicherstellen, dass jedes Teammitglied ohne manuelle Eingriffe den richtigen Zugang erh\u00e4lt, was Zeit spart und Fehler minimiert.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Die automatisierte Erstellung neuer Admin-Benutzer unter Linux erfordert in der Regel mehrere manuelle Befehle (<strong>useradd<\/strong>, <strong>passwd<\/strong>, <strong>usermod<\/strong>). Dieses Skript automatisiert diese Schritte in einem einzigen, zusammenh\u00e4ngenden Prozess. Im Gegensatz zu GUI-basierten Benutzerverwaltungs-Tools kann dieses Skript in gr\u00f6\u00dfere Automatisierungs-Workflows integriert werden, was es flexibler und skalierbarer macht.<\/p>\n<h2>FAQs<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Wie sichert dieses Skript das Passwort?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Es verwendet <strong>perl<\/strong>, um das Passwort vor der Erstellung des Benutzers zu verschl\u00fcsseln, was die Sicherheit erh\u00f6ht.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Kann das Skript die Massenerstellung von Benutzern verarbeiten?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">So wie es geschrieben ist, ist es f\u00fcr die Erstellung eines einzelnen Benutzers gedacht. Es kann jedoch f\u00fcr Massenoperationen ge\u00e4ndert werden.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Ist es mit allen Linux-Distributionen kompatibel?<\/strong>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Das Skript sollte auf den meisten Linux-Distributionen funktionieren, die \u00fcber die Bash-Shell und Standard-Dienstprogramme f\u00fcr die Benutzerverwaltung verf\u00fcgen.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>Folgen<\/h2>\n<p>Dieses Skript ist zwar ein leistungsf\u00e4higes Tool f\u00fcr Systemadministrator:innen, aber es ist wichtig, sich \u00fcber seine Auswirkungen auf die Sicherheit im Klaren zu sein. Die ordnungsgem\u00e4\u00dfe Verwaltung von Benutzerrechten ist f\u00fcr die Systemsicherheit entscheidend. Durch Missbrauch oder Fehler im Skript k\u00f6nnten versehentlich zu viele Berechtigungen erteilt werden.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\">Testen Sie das Skript immer zuerst in einer nicht produktiven Umgebung.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\">Implementieren Sie Protokollierung, um die Verwendung und Ausgabe des Skripts zu verfolgen.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\">\u00dcberpr\u00fcfen Sie regelm\u00e4\u00dfig die vom Skript erstellten Benutzerkonten und kontrollieren Sie diese.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Abschlie\u00dfend zeigt dieses Skript beispielhaft, wie Automatisierung administrative Aufgaben in Linux-Umgebungen rationalisieren kann. F\u00fcr eine umfassende <a href=\"https:\/\/www.ninjaone.com\/de\/rmm\/it-automatisierung\/\">IT-Verwaltung und -Automatisierung<\/a> stellen L\u00f6sungen wie NinjaOne die notwendigen Tools und die Infrastruktur zur Verf\u00fcgung. Sie bieten robuste Unterst\u00fctzung f\u00fcr Aufgaben wie diese und gew\u00e4hrleisten <a href=\"https:\/\/www.ninjaone.com\/de\/effizienz\/\" target=\"_blank\" rel=\"noopener\">Effizienz<\/a> und Sicherheit bei der Verwaltung von IT-Umgebungen.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4211],"use_cases":[4309],"class_list":["post-419256","script_hub","type-script_hub","status-publish","hentry","script_hub_category-linux"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/419256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=419256"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=419256"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=419256"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=419256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}