bootstrap.sh hinzugefügt
First init
This commit is contained in:
parent
e16e39e18c
commit
fd849ab258
1 changed files with 39 additions and 0 deletions
39
bootstrap.sh
Normal file
39
bootstrap.sh
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
USERNAME="skulladmin"
|
||||
SSH_KEY_URL="https://raw.githubusercontent.com/skulldev-de/kevinheyer/trusted-ssh-keys/main/trusted_ssh_keys"
|
||||
SSH_DIR="/home/$USERNAME/.ssh"
|
||||
|
||||
echo "[+] Creating user '$USERNAME' if it doesn't exist..."
|
||||
if ! id "$USERNAME" &>/dev/null; then
|
||||
useradd -m -s /bin/bash "$USERNAME"
|
||||
fi
|
||||
|
||||
echo "[+] Setting up SSH directory..."
|
||||
mkdir -p "$SSH_DIR"
|
||||
curl -fsSL "$SSH_KEY_URL" -o "$SSH_DIR/authorized_keys"
|
||||
chown -R "$USERNAME:$USERNAME" "$SSH_DIR"
|
||||
chmod 700 "$SSH_DIR"
|
||||
chmod 600 "$SSH_DIR/authorized_keys"
|
||||
|
||||
echo "[+] Adding user to sudo group..."
|
||||
usermod -aG sudo "$USERNAME"
|
||||
|
||||
echo "[+] Configuring passwordless sudo for $USERNAME..."
|
||||
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > "/etc/sudoers.d/$USERNAME"
|
||||
chmod 440 "/etc/sudoers.d/$USERNAME"
|
||||
|
||||
echo "[+] Disabling SSH root login..."
|
||||
sed -i 's/^#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
|
||||
systemctl restart sshd
|
||||
|
||||
echo "[+] Setting timezone to Europe/Berlin..."
|
||||
timedatectl set-timezone Europe/Berlin
|
||||
|
||||
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
|
||||
|
||||
echo "[✓] Bootstrap complete."
|
Loading…
Add table
Reference in a new issue