OpenSSH server configuration directives¶
Synopsis¶
/etc/ssh/sshd_config
/etc/ssh/sshd_config.d/*.conf
Keyword argument [argument …]
Match criterion pattern [criterion pattern …]
Keyword argument
Description¶
sshd_config is the configuration file of the OpenSSH server, sshd(8).
Each line holds a keyword followed by one or more arguments, separated by spaces (or an optional =).
Keywords are case-insensitive; arguments are case-sensitive.
Lines starting with #, and empty lines, are ignored.
Arguments containing spaces can be enclosed in double quotes.
For most keywords, the first value read is used and later values are ignored.
Keywords that accept lists, such as AllowUsers, AcceptEnv, HostKey, ListenAddress and Port, accumulate values from every occurrence instead.
Include reads further files at the point where it appears.
On Debian, Ubuntu, AlmaLinux, Rocky Linux and Arch, /etc/ssh/sshd_config has Include /etc/ssh/sshd_config.d/*.conf before any active (uncommented) setting, so drop-in files are read before the active settings of the main file and, because the first value wins, take precedence over them.
On Gentoo the Include line is near the end of the file, after the commented-out defaults, with a comment saying that all Match blocks must follow it; a setting uncommented above it is read first and takes precedence over the drop-in files.
Drop-in files are read in lexical order of their names.
This page was checked against the following OpenSSH packages in the Magellanic labs:
| Distribution | OpenSSH |
|---|---|
| Debian 13 | 10.0p1 (1:10.0p1-7+deb13u4) |
| Ubuntu 26.04 LTS | 10.2p1 (1:10.2p1-2ubuntu3.8) |
| AlmaLinux 10, Rocky Linux 10 | 9.9p1 |
| Arch Linux (snapshot 2026-11-01) | 10.6p1 |
| Gentoo with OpenRC (snapshot 2026-11-07) | 10.6p2 |
The Default columns below give the built-in default, as printed by sshd -T -f /dev/null (which reads no configuration file).
It was the same on every listed distribution unless a note says otherwise.
On AlmaLinux 10 and Rocky Linux 10, the algorithm lists that are actually used come from the system crypto policy rather than these built-in defaults; see Cryptography.
Distributions change several defaults in the files they ship; see Distribution settings.
Only the most commonly used directives are listed; sshd_config(5) on your system is the complete list for its version.
Value types¶
- yes/no: a boolean.
- Time: seconds, or a number with a unit:
s,m,h,dorw(for example90s,2m,1h30m).0usually means no limit. - Pattern list: comma-separated patterns, where
*matches any characters,?one character, and a leading!negates a pattern. - Algorithm list: comma-separated names. A leading
+appends to the default list,-removes from it, and^places the names at the front of it.
Authentication¶
| Directive | Values | Default | Description |
|---|---|---|---|
PubkeyAuthentication |
yes/no | yes |
Allow public key authentication. |
AuthorizedKeysFile |
Paths, or none |
.ssh/authorized_keys .ssh/authorized_keys2 |
Files that list a user's authorised public keys. Relative paths are relative to the user's home directory. Tokens such as %h (home directory), %u (user name) and %% are expanded. |
AuthorizedKeysCommand |
Command, or none |
none |
A program that prints authorised keys for a user, used in addition to AuthorizedKeysFile. |
AuthorizedKeysCommandUser |
User name | none |
The account AuthorizedKeysCommand runs as. Required when a command is set. |
PasswordAuthentication |
yes/no | yes |
Allow the password method. |
KbdInteractiveAuthentication |
yes/no | yes |
Allow the keyboard-interactive method. With UsePAM yes, this lets PAM ask for a password or other credentials. ChallengeResponseAuthentication is a deprecated alias. |
PermitEmptyPasswords |
yes/no | no |
Allow password logins to accounts with an empty password. |
UsePAM |
yes/no | no |
Use PAM for account and session checks and for keyboard-interactive authentication. |
AuthenticationMethods |
any, or lists of methods |
any |
Methods that must all succeed, in order. Each space-separated list is an alternative; methods within a list are comma-separated, for example publickey,keyboard-interactive. |
PubkeyAcceptedAlgorithms |
Algorithm list | Version-dependent | Signature algorithms accepted for public key authentication. |
PubkeyAuthOptions |
none, touch-required, verify-required |
none |
Require FIDO security keys to confirm user presence (touch-required) or user verification such as a PIN (verify-required). |
TrustedUserCAKeys |
Path, or none |
none |
Public keys of certificate authorities whose user certificates are accepted. |
AuthorizedPrincipalsFile |
Path, or none |
none |
File listing the certificate principals accepted for a user. Without it, a certificate must list the user's name as a principal. |
RevokedKeys |
Path, or none |
none |
Revoked public keys or certificates, as a plain list or a key revocation list (KRL). |
HostbasedAuthentication |
yes/no | no |
Allow authentication based on the client host's key (hostbased). |
GSSAPIAuthentication |
yes/no | no |
Allow Kerberos authentication through GSSAPI. |
KerberosAuthentication |
yes/no | no |
Check passwords against Kerberos. |
StrictModes |
yes/no | yes |
Before accepting keys, check that the user's home directory, ~/.ssh and key files are owned by the user or root and not writable by others. |
MaxAuthTries |
Number | 6 |
Authentication attempts allowed per connection. Failures beyond half this number are logged. |
LoginGraceTime |
Time | 120 |
Time allowed to complete authentication before the server disconnects. 0 means no limit. |
Access control¶
| Directive | Values | Default | Description |
|---|---|---|---|
PermitRootLogin |
yes, prohibit-password, forced-commands-only, no |
prohibit-password |
Whether root can log in. prohibit-password allows root only with public keys or other non-password methods. forced-commands-only allows public keys only when the key has a command= option. without-password is a deprecated alias for prohibit-password, and sshd -T prints it on Debian 13, AlmaLinux 10 and Rocky Linux 10. |
AllowUsers |
User patterns | None (all users) | Only these users may log in. A pattern of the form USER@HOST also restricts the client host; HOST may be an address in CIDR form, such as alice@192.0.2.0/24. |
DenyUsers |
User patterns | None | These users may not log in. Checked before AllowUsers. |
AllowGroups |
Group patterns | None (all groups) | Only members of these groups (primary or supplementary) may log in. |
DenyGroups |
Group patterns | None | Members of these groups may not log in. Checked before AllowGroups. |
MaxStartups |
N or start:rate:full |
10:30:100 |
Limit on concurrent unauthenticated connections. With three values, new connections are refused at random with probability rate% once start are pending, rising to 100% at full. |
PerSourceMaxStartups |
Number, or none |
none |
Limit on concurrent unauthenticated connections from one source network. |
PerSourcePenalties |
no, or condition:time settings |
Enabled (crash:90 authfail:5 noauth:1 grace-exceeded:10 …) |
Temporarily refuse connections from a source network after crashes, failed authentication or other suspicious behaviour. The full default list differs between versions; see sshd -T. |
PerSourceNetBlockSize |
IPv4bits:IPv6bits |
32:128 |
Size of the source networks used by PerSourceMaxStartups and PerSourcePenalties. |
RefuseConnection |
yes/no | no |
Close the connection immediately. Useful only inside a Match block. |
Banner |
Path, or none |
none |
A file shown to clients before authentication. |
UseDNS |
yes/no | no |
Look up the client's host name and check that it resolves back to the client's address. When no, only addresses, not host names, can be used in from= options in authorized_keys and in Match Host. |
Users and groups are refused if they match a deny directive, or if any allow directive is set and they don't match it.
AllowUsers, DenyUsers, AllowGroups and DenyGroups may appear more than once; each occurrence adds to the list.
Only names are valid, not numeric IDs.
Listening¶
| Directive | Values | Default | Description |
|---|---|---|---|
Port |
Number | 22 |
Port to listen on. May be repeated. |
ListenAddress |
address, address:port or [address]:port |
0.0.0.0:22 and [::]:22 |
Local addresses to listen on. May be repeated. |
AddressFamily |
any, inet, inet6 |
any |
Address families to use. |
On Ubuntu 26.04, sshd is started through the systemd socket unit ssh.socket, which listens on the port itself; the Port and ListenAddress settings are translated into that unit's configuration by a generator when systemd reloads its configuration.
Forwarding¶
| Directive | Values | Default | Description |
|---|---|---|---|
DisableForwarding |
yes/no | no |
Disable all forwarding: X11, agent, TCP and Unix socket. Overrides the other forwarding directives. |
AllowTcpForwarding |
yes, all, no, local, remote |
yes |
TCP port forwarding (ssh -L, -R, -D). local and remote are from the client's point of view. |
AllowStreamLocalForwarding |
yes, all, no, local, remote |
yes |
Unix-domain socket forwarding. |
AllowAgentForwarding |
yes/no | yes |
Forwarding of the client's ssh-agent. |
GatewayPorts |
no, yes, clientspecified |
no |
Whether remote forwardings (ssh -R) listen only on loopback (no), on all addresses (yes), or where the client asks. |
PermitOpen |
host:port list, any or none |
any |
Destinations allowed for local forwardings (ssh -L). |
PermitListen |
[host:]port list, any or none |
any |
Addresses allowed for remote forwardings (ssh -R). |
PermitTunnel |
yes, point-to-point, ethernet, no |
no |
tun device forwarding (ssh -w). |
X11Forwarding |
yes/no | no |
X11 forwarding (ssh -X). |
X11UseLocalhost |
yes/no | yes |
Bind the forwarded X11 display to the loopback address. |
X11DisplayOffset |
Number | 10 |
First display number used for X11 forwarding. |
Disabling forwarding doesn't stop a user who has shell access from running their own forwarding software.
Session¶
| Directive | Values | Default | Description |
|---|---|---|---|
PermitTTY |
yes/no | yes |
Allow a pseudo-terminal to be allocated. |
MaxSessions |
Number | 10 |
Sessions (shells, commands, subsystems) allowed on one connection. |
ClientAliveInterval |
Time | 0 |
Send a keep-alive message through the encrypted channel when the client has been silent this long. 0 disables it. |
ClientAliveCountMax |
Number | 3 |
Unanswered keep-alive messages before the server disconnects. |
TCPKeepAlive |
yes/no | yes |
Send TCP keep-alive packets. |
ChannelTimeout |
type=interval list, or none |
none |
Close channels of the given types (for example session or direct-tcpip) after they have been inactive this long. |
UnusedConnectionTimeout |
Time, or none |
none |
Close authenticated connections that have no open channels after this long. |
PrintMotd |
yes/no | yes |
Print /etc/motd at interactive login. |
PrintLastLog |
yes/no | yes |
Print the date and source of the user's previous login. Not listed by sshd -T on Arch Linux. |
AcceptEnv |
Variable name patterns | None | Environment variables the client may send. |
SetEnv |
NAME=value list |
None | Environment variables set for every session. |
PermitUserEnvironment |
yes/no, or a pattern list | no |
Process ~/.ssh/environment and environment= options in authorized_keys. |
PermitUserRC |
yes/no | yes |
Run ~/.ssh/rc at login. |
ForceCommand |
Command, or none |
none |
Run this command instead of the one the client requests. The original request is in SSH_ORIGINAL_COMMAND. |
ChrootDirectory |
Path, or none |
none |
chroot(2) to this directory after authentication. It and every directory above it must be owned by root and not writable by anyone else. |
Subsystem |
name command |
None built in; see Distribution settings | Programs for named subsystems. internal-sftp uses the SFTP server built into sshd. |
Cryptography¶
| Directive | Values | Default | Description |
|---|---|---|---|
HostKey |
Path | /etc/ssh/ssh_host_ecdsa_key, /etc/ssh/ssh_host_ed25519_key, /etc/ssh/ssh_host_rsa_key |
Private host key files. May be repeated. Version-dependent: OpenSSH 10.6p1 (Arch) and 10.6p2 (Gentoo) also list /etc/ssh/ssh_host_mldsa44_ed25519_key. |
KexAlgorithms |
Algorithm list | Version-dependent. Begins mlkem768x25519-sha256 from OpenSSH 10.0 (Debian, Ubuntu, Arch, Gentoo); begins sntrup761x25519-sha512 in 9.9p1 (AlmaLinux, Rocky Linux) |
Key exchange algorithms. |
Ciphers |
Algorithm list | chacha20-poly1305@openssh.com,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr; in 9.9p1 (AlmaLinux, Rocky Linux) the same ciphers in the order chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com |
Symmetric ciphers. |
MACs |
Algorithm list | Version-dependent; begins umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com |
Message authentication codes. |
HostKeyAlgorithms |
Algorithm list | Version-dependent | Host key signature algorithms the server offers. |
CASignatureAlgorithms |
Algorithm list | Version-dependent | Algorithms allowed for certificate authorities to sign certificates. |
RequiredRSASize |
Bits | 1024 |
Smallest RSA key accepted for user and host-based authentication. Can only be raised. |
RekeyLimit |
bytes [time] |
default none (shown as 0 0) |
Renegotiate session keys after this much data or time. The default amount depends on the cipher. |
FingerprintHash |
md5, sha256 |
sha256 |
Hash used for key fingerprints in log messages. |
On AlmaLinux 10 and Rocky Linux 10, the algorithm lists and RequiredRSASize are set by the system-wide crypto policy, which is included through /etc/ssh/sshd_config.d/40-redhat-crypto-policies.conf from /etc/crypto-policies/back-ends/opensshserver.config.
With the DEFAULT policy, RequiredRSASize is 2048 and KexAlgorithms begins with mlkem768x25519-sha256, as on the other distributions.
List the algorithms a build supports with ssh -Q kex, ssh -Q cipher, ssh -Q mac and ssh -Q key.
Logging¶
| Directive | Values | Default | Description |
|---|---|---|---|
LogLevel |
QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, DEBUG3 |
INFO |
Amount of detail logged. DEBUG and DEBUG1 are the same. Debug levels log private information about users. |
SyslogFacility |
DAEMON, USER, AUTH, AUTHPRIV, LOCAL0 to LOCAL7 |
AUTH |
Syslog facility for log messages. |
LogVerbose |
Pattern list | None | Extra detailed logging for particular source files and functions, for debugging. |
At INFO, a successful login is logged with the method and, for public keys, the key type and fingerprint, for example Accepted publickey for alice from 192.0.2.10 port 50122 ssh2: ED25519 SHA256:….
On systemd distributions these messages are in the journal of the SSH service unit; on Gentoo with OpenRC they go to the system logger, which with Gentoo's sysklogd configuration writes them to /var/log/auth.log.
Match blocks¶
A Match line starts a conditional block.
If every criterion on the line matches the connection, the keywords that follow apply to it, until the next Match line or the end of the file.
Settings in a matching block override the global value of the same keyword for that connection, wherever the global value was set.
If several matching blocks set the same keyword, the first one applies.
Because every line after a Match line belongs to the block, Match blocks are normally placed at the end of a file.
Match All matches every connection, and is commonly used to end a block early.
| Criterion | Matches |
|---|---|
User |
The user name being logged in to. |
Group |
The user's groups. |
Host |
The client's host name (only meaningful with UseDNS yes). |
Address |
The client's IP address; CIDR ranges such as 198.51.100.0/24 or 2001:db8::/32 are allowed. |
LocalAddress |
The server address the connection arrived on. |
LocalPort |
The server port the connection arrived on. |
RDomain |
The routing domain (VRF) the connection arrived in. |
Invalid-User |
A requested user name that doesn't match any account. Takes no pattern. |
Version |
The server's version string, for example OpenSSH_10.0. Not accepted by OpenSSH 9.9p1 on AlmaLinux 10 and Rocky Linux 10 (Unsupported Match attribute Version). |
All |
Every connection. |
Patterns are pattern lists, so Match User alice,bob and Match Address !192.0.2.0/24 are valid.
Check sshd_config(5) on your system for criteria added in later releases.
Only some keywords are accepted inside a Match block, mostly those that control authentication, access and forwarding.
sshd -t reports a keyword that isn't allowed there.
Distribution settings¶
Settings in the files each distribution ships, as found in the Magellanic lab images.
Lines marked cloud come from cloud-init (/etc/ssh/sshd_config.d/50-cloud-init.conf) or from cloud image settings, and are not present on a system installed from the normal installer.
| Setting | Debian 13 | Ubuntu 26.04 | AlmaLinux / Rocky 10 | Arch | Gentoo |
|---|---|---|---|---|---|
| Service name | ssh |
ssh (started by ssh.socket) |
sshd |
sshd |
sshd |
Include of sshd_config.d/*.conf |
Before any active setting | Before any active setting | Before any active setting | Before any active setting | Near the end, after the commented-out defaults (quoted path) |
UsePAM |
yes |
yes |
yes |
yes |
yes |
PasswordAuthentication |
no (cloud) |
no (cloud) |
no (cloud) |
no (cloud) |
no |
KbdInteractiveAuthentication |
no |
no |
no (as ChallengeResponseAuthentication) |
no |
Default (yes) |
PermitRootLogin |
Default | Default | Default | Default | Default |
X11Forwarding |
yes |
yes |
yes |
Default (no) |
Default (no) |
PrintMotd |
no |
no |
no |
no |
no |
AuthorizedKeysFile |
Default | Default | .ssh/authorized_keys |
.ssh/authorized_keys |
Default |
AuthorizedKeysCommand |
Default | Default | Default | userdbctl ssh-authorized-keys %u (drop-in from systemd) |
Default |
GSSAPIAuthentication |
Default | Default | yes |
Default | Default |
SyslogFacility |
Default | Default | AUTHPRIV |
Default | Default |
ClientAliveInterval |
120 (cloud) |
Default | Default | Default | Default |
AcceptEnv |
LANG LC_* COLORTERM NO_COLOR |
LANG LC_* COLORTERM NO_COLOR |
None | None | LANG, LC_* variables, LANGUAGE, COLORTERM |
Subsystem sftp |
/usr/lib/openssh/sftp-server |
/usr/lib/openssh/sftp-server |
/usr/libexec/openssh/sftp-server |
/usr/lib/ssh/sftp-server |
/usr/lib64/misc/sftp-server |
| Algorithms | Default | Default | System crypto policy | Default | Default |
The Gentoo values were observed on Gentoo with OpenRC, where the service is controlled with rc-service sshd.
On Gentoo with a systemd profile, systemd also installs the 20-systemd-userdb.conf drop-in that sets AuthorizedKeysCommand, as on Arch.
Examples¶
Show the configuration sshd would use, after reading every file:
Show the configuration that applies to one connection, including Match blocks:
Check the configuration files for errors without changing the running server:
A drop-in file that allows only public keys and only members of one group, and lets one group use passwords from an internal network:
# /etc/ssh/sshd_config.d/10-example.conf
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
AllowGroups ssh-users sftp-only
Match Group sftp-only Address 198.51.100.0/24
PasswordAuthentication yes
ForceCommand internal-sftp
ChrootDirectory /srv/sftp/%u
DisableForwarding yes
Files¶
| Path | Purpose |
|---|---|
/etc/ssh/sshd_config |
Main server configuration file. |
/etc/ssh/sshd_config.d/*.conf |
Drop-in files, read where the Include line appears. |
/etc/ssh/ssh_host_*_key, /etc/ssh/ssh_host_*_key.pub |
Host private and public keys. |
~/.ssh/authorized_keys |
A user's authorised public keys (default AuthorizedKeysFile). |
/etc/ssh/moduli |
Diffie-Hellman groups for the diffie-hellman-group-exchange-* key exchange methods. |
/etc/crypto-policies/back-ends/opensshserver.config |
Algorithm settings from the system crypto policy (AlmaLinux, Rocky Linux and RHEL). |
See also¶
sshd_config(5),sshd(8)andssh_config(5)(for thePATTERNSsection), from the OpenSSH versions listed above- OpenSSH manual pages and release notes, for changes between versions
- How to harden the SSH server
Related¶
- Tutorial: Log in with SSH keys
- How-to: How to harden the SSH server
- Explanation: How SSH authentication works