Update Linux/SSH/README.md

This commit is contained in:
2025-01-06 08:58:44 +00:00
parent daac79798e
commit 0e2e00705b

View File

@@ -103,6 +103,9 @@ else
log "Host-Schlüssel ssh_host_ed25519_key ist bereits vorhanden."
fi
sudo rm -f $SSH_CONFIG_DIR/*
echo "Include $SSH_CONFIG_DIR/*" | sudo tee $SSH_MAIN_CONFIG > /dev/null
echo -en "${BLUE}Welche Benutzer dürfen sich per SSH anmelden? (Benutzer durch ${WHITE}Leerzeichen${BLUE} trennen): ${RESET}"
read SSH_USERS
@@ -137,6 +140,49 @@ for user in $SSH_USERS; do
fi
done
warn "Erstelle SSH-Konfigurationsdatei..."
sudo tee $SSH_CONFIG_FILE > /dev/null <<EOL
# SSHD Config Maximale Sicherheit (Nur IPv4)
Include $SSH_CONFIG_DIR
AddressFamily inet
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_ed25519_key
KexAlgorithms curve25519-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,diffie-hellman-group14-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes256-ctr
MACs hmac-sha2-512,hmac-sha2-256
SyslogFacility AUTHPRIV
LogLevel VERBOSE
LoginGraceTime 30s
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding no
PrintMotd no
AuthorizedKeysFile .ssh/authorized_keys
Subsystem sftp /usr/lib/openssh/sftp-server
ClientAliveInterval 300
ClientAliveCountMax 2
AllowUsers $VALID_USERS
EOL
warn "Prüfe SSH-Konfiguration..."
sudo sshd -t && sudo systemctl restart sshd && log "SSH-Dienst erfolgreich neu gestartet."
log "Setup abgeschlossen! Nur folgende Benutzer dürfen sich per SSH anmelden: ${WHITE}$VALID_USERS"
log "Prüfe SSH-Konfiguration..."
if sudo sshd -t && sudo systemctl restart sshd; then
log "SSH-Dienst erfolgreich neu gestartet."