Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计提醒

user-management用户管理

Agent Skill

user-management 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

881

周安装

36

GitHub Stars

18

下载量

282
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:user-management(用户管理)
来源仓库:https://github.com/bagelhole/devops-security-agent-skills
仓库路径:skills/user-management
安装命令:
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill user-management
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill user-management

简介

用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于根据关键词或任务场景进行信息检索和筛选的场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装使用。
  • 安装前需确认权限范围和维护状态,注意可能触发联网或文件操作。
  • user-management 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

User Management

Manage users, groups, permissions, sudo access, PAM modules, and LDAP integration on Linux systems. Includes practical scripts for bulk user operations and access auditing.

When to Use

  • Creating and managing local user accounts on Linux servers
  • Configuring sudo access with fine-grained privilege controls
  • Setting up group-based access control for teams
  • Integrating Linux hosts with LDAP or Active Directory for centralized auth
  • Auditing user accounts, permissions, and access patterns
  • Automating bulk user provisioning and deprovisioning

Prerequisites

  • Root or sudo access on the target system
  • shadow-utils package (provides useradd, usermod, etc.) -- installed by default
  • libpam-modules for PAM configuration
  • For LDAP: sssd, realmd, libpam-ldapd, or nslcd packages
  • For auditing: auditd package

User Operations

Creating Users

# Create a user with home directory, default shell, and comment
useradd -m -s /bin/bash -c "Jane Smith" jsmith

# Set the user's password interactively
passwd jsmith

# Create a user with a specific UID and primary group
useradd -m -s /bin/bash -u 1500 -g developers -c "Deploy Account" deploy

# Create a system account (no home, no login shell) for running services
useradd -r -s /usr/sbin/nologin -d /opt/myapp -c "MyApp Service Account" myapp

# Create a user with an expiration date (contractor access)
useradd -m -s /bin/bash -e 2025-12-31 -c "Contractor - Bob Lee" blee

# Create user and add to multiple supplementary groups at creation time
useradd -m -s /bin/bash -G docker,developers,ssh-users -c "Dev User" devuser

Modifying Users

# Add a user to a supplementary group (preserving existing groups with -a)
usermod -aG sudo jsmith
usermod -aG docker,developers jsmith

# Change the user's login shell
usermod -s /bin/zsh jsmith

# Change the user's home directory and move existing files
usermod -d /home/jsmith-new -m jsmith

# Lock a user account (disable login without deleting)
usermod -L jsmith

# Unlock a user account
usermod -U jsmith

# Set an account expiration date
usermod -e 2025-06-30 blee

# Change a user's login name
usermod -l jsmith-new jsmith

# Force password change on next login
chage -d 0 jsmith

# Set password aging: min 7 days, max 90 days, warn 14 days before
chage -m 7 -M 90 -W 14 jsmith

# View password aging info
chage -l jsmith

Deleting Users

# Remove a user and their home directory
userdel -r jsmith

# Remove a user but keep their home directory (for auditing)
userdel jsmith

# Find and reassign files owned by a deleted user (by UID)
find / -uid 1500 -exec chown newowner:newgroup {} \;

Group Management

# Create a new group
groupadd developers

# Create a group with a specific GID
groupadd -g 2000 devops

# Add a user to a group
usermod -aG developers jsmith
# Alternative using gpasswd
gpasswd -a jsmith developers

# Remove a user from a group
gpasswd -d jsmith developers

# Set group administrators (can add/remove members without root)
gpasswd -A jsmith developers

# Delete a group
groupdel developers

# List all groups a user belongs to
groups jsmith
id jsmith

# List all members of a group
getent group developers

# Show all groups on the system
cat /etc/group | cut -d: -f1 | sort

Sudo Configuration

# Always edit sudoers via visudo (syntax validation prevents lockout)
visudo

# Better: use drop-in files in /etc/sudoers.d/
visudo -f /etc/sudoers.d/developers

/etc/sudoers.d/developers

# Allow the developers group to restart specific services
%developers ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart myapp, /usr/bin/systemctl status myapp

# Allow a deploy user full sudo with no password
deploy ALL=(ALL) NOPASSWD: ALL

# Allow ops team to run docker commands only
%ops ALL=(ALL) NOPASSWD: /usr/bin/docker, /usr/bin/docker-compose

# Allow a user to run commands as a specific service account
jsmith ALL=(myapp) NOPASSWD: /opt/myapp/bin/*

# Restrict to specific hosts (useful with centralized sudoers)
jsmith dbservers=(root) /usr/bin/systemctl restart postgresql

# Log all sudo commands to a dedicated file
Defaults log_output
Defaults!/usr/bin/sudoreplay !log_output
Defaults logfile="/var/log/sudo.log"

# Require password re-entry every 5 minutes (default is 15)
Defaults timestamp_timeout=5

# Require password for sudo even if user has NOPASSWD elsewhere
Defaults:jsmith !authenticate
# Validate sudoers syntax without applying
visudo -c

# Check what sudo permissions a user has
sudo -l -U jsmith

# Test a specific sudo command as a user
sudo -u myapp /opt/myapp/bin/healthcheck.sh

File Permissions and ACLs

# Standard permissions
chmod 755 /opt/myapp           # rwxr-xr-x
chmod 640 /etc/myapp.conf      # rw-r-----
chmod u+x script.sh            # Add execute for owner
chmod g+w shared-dir/          # Add write for group
chmod o-rwx private-file       # Remove all permissions for others

# Change ownership
chown deploy:developers /opt/myapp
chown -R deploy:developers /opt/myapp/   # Recursive

# Set the SGID bit (new files inherit group ownership)
chmod g+s /opt/shared/

# Set the sticky bit (only owner can delete their files)
chmod +t /tmp/shared/

# Access Control Lists (ACLs) for fine-grained control
# Grant read-execute to a specific user on a directory
setfacl -m u:jsmith:rx /opt/myapp/logs/

# Grant read-write to a group
setfacl -m g:developers:rw /opt/shared/

# Set default ACL (applied to new files created in the directory)
setfacl -d -m g:developers:rw /opt/shared/

# View ACLs
getfacl /opt/shared/

# Remove a specific ACL entry
setfacl -x u:jsmith /opt/myapp/logs/

# Remove all ACLs
setfacl -b /opt/shared/

PAM Configuration

# PAM config files are in /etc/pam.d/
# Each file controls auth for a specific service (sshd, login, sudo, etc.)

# Enforce password complexity via pam_pwquality
# /etc/pam.d/common-password (Debian) or /etc/pam.d/system-auth (RHEL)
password requisite pam_pwquality.so retry=3 minlen=12 dcredit=-1 ucredit=-1 ocredit=-1 lcredit=-1

# Configure /etc/security/pwquality.conf
minlen = 12
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
maxrepeat = 3
dictcheck = 1

# Limit concurrent logins per user
# /etc/security/limits.conf
jsmith hard maxlogins 3
@developers hard maxlogins 5

# Lock account after 5 failed login attempts
# /etc/pam.d/common-auth (Debian)
auth required pam_faillock.so preauth silent deny=5 unlock_time=900
auth required pam_faillock.so authfail deny=5 unlock_time=900

# View failed login attempts
faillock --user jsmith

# Unlock a locked account
faillock --user jsmith --reset

LDAP / Active Directory Integration

# Install SSSD and realmd for AD integration (Ubuntu/Debian)
apt install -y sssd realmd adcli sssd-tools libnss-sss libpam-sss

# Install SSSD and realmd (RHEL/CentOS)
dnf install -y sssd realmd adcli sssd-tools oddjob oddjob-mkhomedir

# Discover and join an Active Directory domain
realm discover corp.example.com
realm join corp.example.com -U admin@CORP.EXAMPLE.COM

# Verify the join
realm list

# Allow specific AD groups to log in
realm permit -g "Linux Admins@corp.example.com"
realm permit -g "Developers@corp.example.com"

# Deny all except permitted groups
realm deny --all
realm permit -g "Linux Admins@corp.example.com"

# Restart SSSD after config changes
systemctl restart sssd

# Test LDAP user lookup
id jsmith
getent passwd jsmith

# Grant sudo to an AD group
echo '%linux\ admins ALL=(ALL) ALL' > /etc/sudoers.d/ad-admins

Bulk User Management Scripts

Bulk User Creation from CSV

#!/bin/bash
# bulk-create-users.sh
# CSV format: username,fullname,groups,shell
# Example: jsmith,Jane Smith,developers;docker,/bin/bash

CSV_FILE="${1:?Usage: $0 <users.csv>}"

while IFS=',' read -r username fullname groups shell; do
  # Skip header line
  [[ "$username" == "username" ]] && continue

  if id "$username" &>/dev/null; then
    echo "SKIP: User $username already exists"
    continue
  fi

  # Replace semicolons with commas for -G flag
  group_list="${groups//;/,}"

  useradd -m -s "$shell" -c "$fullname" -G "$group_list" "$username"
  # Generate a random temporary password
  temp_pass=$(openssl rand -base64 12)
  echo "$username:$temp_pass" | chpasswd
  chage -d 0 "$username"   # Force password change at first login

  echo "CREATED: $username (groups: $group_list) temp-pass: $temp_pass"
done < "$CSV_FILE"

Quick Access Audit Commands

# List non-system users (UID >= 1000)
awk -F: '$3 >= 1000 && $3 < 65534 { printf "%-20s UID=%-6s Shell=%s\n", $1, $3, $7 }' /etc/passwd

# List users with sudo access
getent group sudo wheel 2>/dev/null

# Find accounts that have never logged in
lastlog | awk '$0 ~ /Never logged in/ { print $1 }'

# Find accounts with empty passwords
awk -F: '($2 == "" || $2 == "!") { print $1 }' /etc/shadow 2>/dev/null

Troubleshooting

SymptomDiagnostic CommandCommon Fix
User cannot log inpasswd -S username, faillock --user usernameUnlock account, reset password, check shell
"not in sudoers" errorsudo -l -U usernameAdd user to sudo group or create sudoers.d file
Group membership not appliedid username, groups usernameUser must log out and back in for new groups
LDAP/AD user not foundid aduser, sssctl user-show aduserCheck SSSD status, clear cache: sss_cache -E
Permission denied on filels -la file, getfacl fileFix ownership/permissions, check SELinux context
PAM lockout after failed attemptsfaillock --user usernamefaillock --user username --reset
Home directory not createdCheck /etc/login.defs CREATEHOMEUse useradd -m or enable pam_mkhomedir
Password policy not enforcedCheck /etc/pam.d/common-passwordInstall and configure pam_pwquality

Related Skills

  • linux-administration -- General Linux server management
  • ssh-configuration -- SSH key-based authentication for managed users
  • systemd-services -- Service accounts and systemd user instances
  • performance-tuning -- Resource limits per user via cgroups and ulimits

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.64%
按下载量换算103

Claude

28.02%
按下载量换算79

Cursor

16.32%
按下载量换算46

Gemini CLI

9.54%
按下载量换算27

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/bagelhole/devops-security-agent-skills --skill user-management 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills