net/3_Hq-srv_Br-srv.sh

32 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Минимальный скрипт создания пользователей на HQ-SRV
# sudo ./minimal_create_users.sh
# Проверка root
[[ $EUID -ne 0 ]] && { echo "Запустите с sudo"; exit 1; }
echo "Создание пользователей на HQ-SRV..."
# Удаляем существующих пользователей (если нужно пересоздать)
# userdel -r remote_user 2>/dev/null
# userdel -r sshuser 2>/dev/null
# Создание remote_user с UID 2026
useradd -u 2026 -m -s /bin/bash remote_user 2>/dev/null
echo "remote_user:P@ssw0rd" | chpasswd
echo "Создан remote_user (UID: $(id -u remote_user))"
# Создание sshuser
useradd -m -s /bin/bash sshuser 2>/dev/null
echo "sshuser:P@ssw0rd" | chpasswd
echo "sshuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/sshuser
chmod 440 /etc/sudoers.d/sshuser
echo "Создан sshuser с sudo без пароля"
# Проверка
echo -e "\nПроверка:"
id remote_user
id sshuser
sudo -l -U sshuser | grep NOPASSWD
echo -e "\nГотово!"