bootstrap.sh aktualisiert
This commit is contained in:
parent
0ee9c0ea07
commit
6ba2492705
1 changed files with 18 additions and 12 deletions
30
bootstrap.sh
30
bootstrap.sh
|
@ -3,7 +3,7 @@ set -euo pipefail
|
|||
|
||||
# Check for root privileges
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "[✗] Dieses Skript muss als root oder via sudo ausgeführt werden." >&2
|
||||
echo "[✗] Dieses Skript muss als root ausgeführt werden." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -11,31 +11,37 @@ USERNAME="skulladmin"
|
|||
SSH_KEY_URL="https://skulldev.de/Skull-IT/trusted-ssh-keys/raw/branch/main/trusted-ssh-keys"
|
||||
SSH_DIR="/home/$USERNAME/.ssh"
|
||||
|
||||
# Update package list and install necessary packages
|
||||
echo "[+] Updating package list and installing essential packages..."
|
||||
apt-get update -y
|
||||
apt-get install -y sudo curl wget gnupg lsb-release software-properties-common
|
||||
apt-get update
|
||||
apt-get install -y wget
|
||||
|
||||
# Create user if not exists
|
||||
if ! id "$USERNAME" &>/dev/null; then
|
||||
useradd -m -s /bin/bash "$USERNAME"
|
||||
fi
|
||||
|
||||
# Setting up SSH directory and authorized keys
|
||||
echo "[+] Setting up SSH directory..."
|
||||
mkdir -p "$SSH_DIR"
|
||||
curl -fsSL "$SSH_KEY_URL" -o "$SSH_DIR/authorized_keys"
|
||||
wget -O "$SSH_DIR/authorized_keys" "$SSH_KEY_URL"
|
||||
chown -R "$USERNAME:$USERNAME" "$SSH_DIR"
|
||||
chmod 700 "$SSH_DIR"
|
||||
chmod 600 "$SSH_DIR/authorized_keys"
|
||||
|
||||
# Adding user to sudo group
|
||||
echo "[+] Adding user to sudo group..."
|
||||
apt-get install -y sudo
|
||||
usermod -aG sudo "$USERNAME"
|
||||
|
||||
# Configuring passwordless sudo for the user
|
||||
echo "[+] Configuring passwordless sudo for $USERNAME..."
|
||||
mkdir -p /etc/sudoers.d
|
||||
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/$USERNAME"
|
||||
chmod 440 "/etc/sudoers.d/$USERNAME"
|
||||
|
||||
# Setting timezone
|
||||
echo "[+] Setting timezone to Europe/Berlin..."
|
||||
timedatectl set-timezone Europe/Berlin
|
||||
apt-get install -y tzdata
|
||||
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
|
||||
|
||||
echo "[+] Waiting for dpkg lock to be released..."
|
||||
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do
|
||||
sleep 3
|
||||
done
|
||||
|
||||
echo "[✓] Bootstrap complete."
|
||||
echo "[✓] Bootstrap complete."
|
||||
|
|
Loading…
Add table
Reference in a new issue