SSH-Server Hardening: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
= Passwortauthentifizierung abschalten = | = Passwortauthentifizierung abschalten = | ||
* '''vim ''/etc/ssh/sshd_config'' ''' | * '''vim ''/etc/ssh/sshd_config'' ''' | ||
| − | + | ||
| + | ... | ||
| + | Port xyz | ||
... | ... | ||
PubkeyAuthentication yes | PubkeyAuthentication yes | ||
| Zeile 27: | Zeile 29: | ||
X11Forwarding no | X11Forwarding no | ||
... | ... | ||
| + | |||
| + | = Default cipher in die Konfig übertragen= | ||
| + | */usr/sbin/sshd -T | egrep "kexalgorithms|hostbasedacceptedalgorithms|hostkeyalgorithms|pubkeyacceptedalgorithms|macs|ciphers" >> /etc/ssh/sshd_config | ||
= veraltete Cipher-Suites entfernen = | = veraltete Cipher-Suites entfernen = | ||
Aktuelle Version vom 25. Juni 2025, 11:59 Uhr
Passwortauthentifizierung abschalten
- vim /etc/ssh/sshd_config
... Port xyz ... PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys ... PasswordAuthentication no PermitEmptyPasswords no ... UsePAM no ...
- systemctl restart sshd
- Nun werden nur noch Benutzer mit dem entsprechenden privaten Schlüssel unter ~/.ssh/authorized_keys angemeldet
SSH Server Optionen einschränken
- Die AllowTcpForwarding-Option kann ausgenutzt werden, um Firewalls zu umgehen
- Die X11Forwarding-Option kann benutzt werden, um graphische Programme über SSH zu tunneln
- an sich stellt diese Option kein Sicherheitsrisiko dar
- jedoch wird sie selten benutzt und ist selbst dann sehr langsam
- vim /etc/ssh/sshd_config
... AllowTcpForwarding no #GatewayPorts no X11Forwarding no ...
Default cipher in die Konfig übertragen
- /usr/sbin/sshd -T | egrep "kexalgorithms|hostbasedacceptedalgorithms|hostkeyalgorithms|pubkeyacceptedalgorithms|macs|ciphers" >> /etc/ssh/sshd_config
veraltete Cipher-Suites entfernen
- vim /etc/ssh/sshd_config
... KexAlgorithms 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 Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128-etm@openssh.com HostKeyAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256 RequiredRSASize 3072 HostbasedAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256 PubkeyAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256 ...
Überprüfen mit ssh-audit
- apt install ssh-audit
- ssh-audit ip.des.gehärteten.hosts