+ scr/3_create_user.sh
This commit is contained in:
28
scr/3_create_user.sh
Executable file
28
scr/3_create_user.sh
Executable 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
|
||||||
Reference in New Issue
Block a user