5 Commits

Author SHA1 Message Date
patrick 204aedafdb postinstall aktualisiert
harden_ssh
2025-06-17 01:22:00 +02:00
Thorsten Spille e0e9b49bf9 Merge pull request #27 from bashclub/dev
Update postinstall
2024-12-15 16:14:49 +01:00
Thorsten Spille f271c7716b Merge pull request #25 from bashclub/dev
Update postinstall
2024-06-24 15:30:49 +02:00
Thorsten Spille 0b14d9c2c3 Update README.md
Fix for release
2024-06-23 21:44:52 +02:00
Thorsten Spille 603d1f6bc8 Merge pull request #24 from bashclub/dev
proxmox 8.2 postinstaller
2024-06-23 21:22:44 +02:00
2 changed files with 32 additions and 18 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
# proxmox-zfs-postinstall
This script installs and configures basic tools for running a Proxmox Server.
This script installs and configures basic tools for running a new Proxmox Server (Version 8+).
Following settings are made:
- Install and configure zfs-auto-snapshot
- Switch pve-enterprise/pve-no-subscription/pvetest repo
@@ -15,16 +15,16 @@ Following settings are made:
- SSH server hardening
- Install checkzfs
- Install bashclub-zsync
- Install virtio-win ISO
- Create zfspool storage for swap disks if not exists
- Adjust default volblocksize for Proxmox zfspool storage
- Configure proxmox mail delivery with postfix
- Daily check (and download) for new stable virtio-win iso and prune old (unused) versions
- Configure proxmox mail delivery proxmox notifications (pve8)
# Usage
Just download and execute the script, all settings are made interactively.
```
wget -O ./postinstall --no-cache https://github.com/bashclub/proxmox-zfs-postinstall/raw/dev/postinstall
wget -O ./postinstall --no-cache https://github.com/bashclub/proxmox-zfs-postinstall/raw/main/postinstall
bash ./postinstall
```
+26 -12
View File
@@ -522,22 +522,36 @@ pve_conf_backup(){
harden_ssh(){
if [ $ssh_hardening -gt 0 ]; then
log "Hardening ssh server"
rm /etc/ssh/ssh_host_*
log "Creating new SSH host keys"
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N "" > /dev/null 2>&1
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" > /dev/null 2>&1
log "Creating new SSH moduli"
log "Creating backup of current SSH config"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
rm -f /etc/ssh/ssh_host_*
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N "" > /dev/null
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" > /dev/null
if [ $(awk '$5 >= 3071' /etc/ssh/moduli | wc -l) -gt 0 ]; then
awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe
mv /etc/ssh/moduli.safe /etc/ssh/moduli
log "Writing hardened SSH config"
if [[ $VERSION_CODENAME == "bookworm" ]]; then
echo -e "\n# Restrict key exchange, cipher, and MAC algorithms, as per sshaudit.com\n# hardening guide.\nKexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,gss-curve25519-sha256-,diffie-hellman-group16-sha512,gss-group16-sha512-,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256\nCiphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr\nMACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128-etm@openssh.com\nHostKeyAlgorithms ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com" > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
elif [[ $VERSION_CODENAME == "bullseye" ]]; then
sed -i 's/^\#HostKey \/etc\/ssh\/ssh_host_\(rsa\|ed25519\)_key$/HostKey \/etc\/ssh\/ssh_host_\1_key/g' /etc/ssh/sshd_config
echo -e echo -e "\n# Restrict key exchange, cipher, and MAC algorithms, as per sshaudit.com\n# hardening guide.\nKexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256\nCiphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr\nMACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128-etm@openssh.com\nHostKeyAlgorithms ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com" > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
fi
INCLUDE_LINE="Include /etc/ssh/sshd_config.d/*.conf"
grep -qxF "$INCLUDE_LINE" /etc/ssh/sshd_config || echo "$INCLUDE_LINE" >> /etc/ssh/sshd_config
cat << EOF > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
# Hardening profile by bashclub.org
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com
MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com
HostKeyAlgorithms ssh-ed25519,rsa-sha2-512
EOF
if sshd -t; then
systemctl restart ssh.service
else
echo "Fehlerhafte SSH-Konfiguration erkannt. Bitte prüfen: /etc/ssh/sshd_config.d/ssh-audit_hardening.conf"
exit 1
fi
fi
}