Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
sshd listens (default port 22) and handles SSH logins. On RHEL it runs as sshd.service. Settings are in /etc/ssh/sshd_config and the drop-in folder /etc/ssh/sshd_config.d/ (first value wins). After a change, test with sshd -t, then systemctl reload sshd.
sshd -T prints the effective settings after all files are read — the best way to check what really applies.
Zo schrijf je het
sshd [-46DdeGiqTtV] [-C SPEC] [-c CERT] [-E LOG] [-f CONFIG] [-g TIME] [-h KEY] [-o OPTION] [-p PORT]Belangrijkste delen
PortN- Listen port.
PermitRootLoginyes|prohibit-password|no|forced-commands-only- How root may log in.
PasswordAuthenticationyes|no- Allow passwords.
PubkeyAuthenticationyes|no- Allow keys.
AllowUsers,AllowGroups,DenyUsers,DenyGroups- Who may log in.
MaxAuthTriesN- Tries per connection.
ClientAliveIntervalS,ClientAliveCountMaxN- Keepalive and idle timeout.
X11Forwarding,AllowTcpForwarding- Forwarding.
BannerFILE- Text before login.
MatchUser|Group|Address…- Settings for some users or networks.
Opties 19
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Test the config
sshd -tNo output = fine. Always run before a reload.
2Show the effective settings
sshd -T | grep -iE '^(port|permitrootlogin|passwordauthentication|allowgroups)' port 2022 permitrootlogin noWhat really applies after all files.
3Settings for one user and address
sshd -T -C user=lisa,addr=192.168.122.1,host=client | grep -i allowtcpTests Match blocks.
4Reload after a change
systemctl reload sshdExisting sessions stay.
5Debug a failing login
/usr/sbin/sshd -d -p 2222One test connection on port 2222 with full debug output:
ssh -p 2222 user@host.6Status and logs
systemctl status sshd journalctl -u sshd --since -1hFailed logins and errors.
7New port: SELinux and firewall
semanage port -a -t ssh_port_t -p tcp 2022 firewall-cmd --add-port=2022/tcp --permanent; firewall-cmd --reloadWithout these, sshd cannot use or expose the port.
8Different rules for a network
cat /etc/ssh/sshd_config.d/40-match.conf Match Address 192.168.122.0/24 PasswordAuthentication yesPasswords only from the admin network.
9Host key fingerprints (tell users)
for k in /etc/ssh/ssh_host_*_key.pub; do ssh-keygen -lf "$k"; doneUsers compare these at the first connection.
10Audit the SSH config (security)
sshd -T | grep -E '^(permitrootlogin|passwordauthentication|x11forwarding|maxauthtries|permitemptypasswords)'Quick hardening check against your policy.
Niets past bij dit filter.
Bestanden
/etc/ssh/sshd_config- Main config.
/etc/ssh/sshd_config.d/*.conf- Drop-ins (read first; first value wins).
/etc/ssh/ssh_host_*_key- Host keys.
~/.ssh/authorized_keys- Allowed keys per user.
Exitcodes
0 :: Config OK (with -t/-T). 255 :: Error.