42 lines
773 B
Bash
42 lines
773 B
Bash
#!/bin/bash
|
|
|
|
echo "Deployment Debian + Caddy + Directus + Nuxt"
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
#
|
|
# USER
|
|
#
|
|
|
|
echo "Create user"
|
|
|
|
read -p "Enter username: " username
|
|
|
|
if id "$username" &>/dev/null; then
|
|
echo "User '$username' already exists."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Generate and store the password somewhere safe"
|
|
read -s -p "Enter password: " password
|
|
echo
|
|
sudo useradd -m "$username"
|
|
echo "$username:$password" | chpasswd
|
|
|
|
usermod -aG sudo $username
|
|
|
|
echo "User '$username' created with password successfully."
|
|
|
|
#
|
|
# SSH
|
|
#
|
|
|
|
echo "Setup SSH"
|
|
|
|
touch /etc/ssh/sshd_config.d/custom.conf
|
|
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
|
|
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config.d/custom.conf
|
|
systemctl reload ssh |