mirror of
				https://github.com/bashclub/proxmox-zfs-postinstall.git
				synced 2025-11-04 00:32:26 +01:00 
			
		
		
		
	Fix logging of SSH hardening
This commit is contained in:
		@@ -395,11 +395,14 @@ harden_ssh(){
 | 
				
			|||||||
    if [ $ssh_hardening -gt 0 ]; then
 | 
					    if [ $ssh_hardening -gt 0 ]; then
 | 
				
			||||||
        log "Hardening ssh server"
 | 
					        log "Hardening ssh server"
 | 
				
			||||||
        rm /etc/ssh/ssh_host_*
 | 
					        rm /etc/ssh/ssh_host_*
 | 
				
			||||||
        ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ""
 | 
					        log "Creating new SSH host keys"
 | 
				
			||||||
        ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
 | 
					        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"
 | 
				
			||||||
        awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe
 | 
					        awk '$5 >= 3071' /etc/ssh/moduli > /etc/ssh/moduli.safe
 | 
				
			||||||
        mv /etc/ssh/moduli.safe /etc/ssh/moduli
 | 
					        mv /etc/ssh/moduli.safe /etc/ssh/moduli
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        log "Writing hardened SSH config"
 | 
				
			||||||
        if [[ $VERSION_CODENAME == "bookworm" ]]; then
 | 
					        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
 | 
					            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
 | 
					        elif [[ $VERSION_CODENAME == "bullseye" ]]; then
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user