+ scr/3_create_user.sh

This commit is contained in:
fro
2025-10-28 13:05:34 -05:00
parent 19dbbcec5d
commit 33c00ee29b

28
scr/3_create_user.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/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