Files
srv-pub/scr/3_create_user.sh
2025-10-28 13:05:34 -05:00

29 lines
695 B
Bash
Executable File

#!/bin/bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# create new system user / frode klevstul / oct 2025
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$EUID" -ne 0 ]
then echo "error: run as 'root'"
exit
fi
this_file_name=`basename "$0"`
if [ $# -ne 1 ]; then
echo usage: $this_file_name [USERNAME]
exit 1
fi
username=$1
# ---
# create a new non-root user
# ---
adduser --disabled-password --gecos "" $username
mkdir /home/$username/.ssh
cp /root/.ssh/authorized_keys /home/$username/.ssh/
chown $username:$username /home/$username/.ssh/
chown $username:$username /home/$username/.ssh/authorized_keys