sshd_config

Configure the OpenSSH server: listening, authentication, forwarding, access control and logging.

Before you run

The server configuration is distinct from the client ssh_config. Paths, supported options and defaults depend on operating system and OpenSSH version. Keep an existing administrative session open and a recovery path available. Before applying changes, validate the actual configuration with sshd -t and inspect effective settings with sshd -T; these commands may require administrator privileges. Verify a second login before closing the original session. Do not copy example values blindly.

After applying changes, verify that you can sign in and that the intended behavior works in a new SSH session. Keep the current session open until verification succeeds, so you can restore the configuration if necessary.

Examples

Example server configuration. Adapt authentication, paths and access rules to your environment.

Port 22
PermitRootLogin no
PubkeyAuthentication yes
AllowTcpForwarding yes

Validate syntax and inspect effective server settings before applying changes.

sudo sshd -t
sudo sshd -T

Options and examples

PortCommon

Listening TCP port; multiple Port directives are allowed. Ensure the firewall and clients permit the chosen port.

Example
Port 2222
ListenAddressCommon

Local address on which sshd listens. An address can include a port; ensure it exists on the server.

Example
ListenAddress 192.0.2.10
AddressFamily

Select address family: any, inet for IPv4, or inet6 for IPv6.

Example
AddressFamily inet
HostKeyCommon

Path to a server private host key; this is not a user's authentication key. Protect the private file.

Example
HostKey /etc/ssh/ssh_host_ed25519_key
HostCertificate

Path to a server host certificate matching a configured host key.

Example
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
PasswordAuthenticationCommon

Allow or deny password authentication. Verify another login method before disabling it.

Example
PasswordAuthentication no
PubkeyAuthenticationCommon

Allow or deny public key authentication. Server permissions and authorized keys still apply.

Example
PubkeyAuthentication yes
KbdInteractiveAuthenticationCommon

Allow keyboard-interactive authentication. The prompts and available methods depend on the server and authentication backend.

Example
KbdInteractiveAuthentication yes
AuthenticationMethodsCommon

Require one of the space-separated method lists; every comma-separated method in a list must succeed. Each method must also be enabled.

Example
AuthenticationMethods publickey,keyboard-interactive
PermitRootLoginCommon

Control root login: yes, prohibit-password, forced-commands-only, or no. Test an alternative administrative login first.

Example
PermitRootLogin no
PermitEmptyPasswords

Allow accounts with empty passwords to authenticate using password authentication. Enabling this is unsafe.

Example
PermitEmptyPasswords no
AuthorizedKeysFileCommon

Paths to files containing authorized public keys. Relative paths are resolved from the user's home directory; tokens are supported.

Example
AuthorizedKeysFile .ssh/authorized_keys
StrictModesCommon

Check ownership and permissions of user files and home directories before accepting login.

Example
StrictModes yes
AllowUsersCommon

Allow only the listed user name patterns; USER@HOST patterns can constrain the origin. Account access is also subject to other restrictions.

Example
AllowUsers alice bob
DenyUsers

Deny matching user name patterns. Deny rules take precedence over corresponding allow rules.

Example
DenyUsers guest
AllowGroups

Allow only users in matching named groups, subject to other access rules.

Example
AllowGroups sshusers
DenyGroups

Deny users in matching named groups; group names, not numeric IDs, are used.

Example
DenyGroups restricted
AllowTcpForwardingCommon

Control TCP forwarding: yes or all, no, local, or remote. This alone cannot prevent forwarding by users with unrestricted shell access.

Example
AllowTcpForwarding local
DisableForwarding

Disable forwarding features, overriding other forwarding settings. This can break tunnels and agent or X11 forwarding.

Example
DisableForwarding yes
GatewayPortsCommon

Control remote forwarding bind addresses: no binds loopback, yes binds wildcard, and clientspecified permits client-selected addresses. Exposing ports has security implications.

Example
GatewayPorts no
PermitOpen

Restrict destinations for local TCP forwarding; use host:port entries, any, or none. Names are not resolved for matching.

Example
PermitOpen db.example.com:5432
PermitListen

Restrict listening addresses and ports for remote forwarding; GatewayPorts also affects binding.

Example
PermitListen localhost:18080
AllowAgentForwarding

Allow SSH authentication-agent forwarding. A remote process with access to the agent socket can request signatures.

Example
AllowAgentForwarding no
AllowStreamLocalForwarding

Control Unix-domain socket forwarding: yes or all, no, local, or remote.

Example
AllowStreamLocalForwarding no
X11Forwarding

Enable X11 display forwarding. Enable only where needed and understand the remote display access risk.

Example
X11Forwarding no
MaxAuthTriesCommon

Maximum authentication attempts per connection before disconnecting. The server may log failures earlier.

Example
MaxAuthTries 4
MaxSessionsCommon

Maximum shell, login, or subsystem sessions per SSH connection. Setting zero prevents sessions but may still permit forwarding.

Example
MaxSessions 10
MaxStartupsCommon

Limit unauthenticated connections. The start:rate:full form progressively rejects connections under load.

Example
MaxStartups 10:30:100
LoginGraceTimeCommon

Time allowed for authentication; a duration of zero means no time limit.

Example
LoginGraceTime 60s
ClientAliveIntervalCommon

Interval in seconds for encrypted SSH-level client-alive probes; zero disables these probes.

Example
ClientAliveInterval 30
ClientAliveCountMaxCommon

Number of unanswered SSH-level client-alive probes tolerated before disconnecting. Use with ClientAliveInterval.

Example
ClientAliveCountMax 3
TCPKeepAlive

Control TCP keepalive messages. These are separate from encrypted SSH client-alive probes.

Example
TCPKeepAlive yes
UsePAMCommon

Enable PAM integration on builds that support it. PAM policy and available authentication methods vary by system.

Example
UsePAM yes
PermitTTY

Allow allocation of a pseudo-terminal. Disabling it affects interactive sessions.

Example
PermitTTY yes
ForceCommand

Replace the requested command with a fixed command. Validate access and restrictions carefully before enabling.

Example
ForceCommand internal-sftp
SubsystemCommon

Define a named subsystem and its command; internal-sftp is the built-in SFTP server.

Example
Subsystem sftp internal-sftp
ChrootDirectory

Confine a session to a directory after authentication. Directory ownership and permissions are strictly checked; provision required files for the intended session.

Example
ChrootDirectory /srv/sftp/%u
MatchCommon

Start a conditional block for matching users, groups, addresses, or other supported criteria. Only certain directives are permitted inside it.

Example
Match User sftpuser
    ForceCommand internal-sftp
IncludeCommon

Include configuration files by path or glob. Ordering matters because the first obtained value generally applies.

Example
Include /etc/ssh/sshd_config.d/*.conf
LogLevelCommon

Set logging verbosity, such as QUIET, FATAL, ERROR, INFO, VERBOSE, or DEBUG. Detailed logs may expose sensitive information.

Example
LogLevel INFO
SyslogFacility

Choose the syslog facility used for SSH server messages; system logging configuration determines where they appear.

Example
SyslogFacility AUTH
Banner

Send the contents of a specified file before authentication. Use none to disable a configured banner.

Example
Banner /etc/issue.net
AcceptEnv

Allow named client-supplied environment variables. Some variables can bypass restricted environments, so allow only what is needed.

Example
AcceptEnv LANG LC_*
PermitUserEnvironment

Control user-provided environment settings. Enabling them can bypass restrictions through environment variables.

Example
PermitUserEnvironment no
PrintMotd

Control whether sshd prints the message of the day at interactive login. PAM or another service may also print it.

Example
PrintMotd no
Compression

Control compression. Supported values and timing vary by OpenSSH version.

Example
Compression no
RekeyLimit

Set the data threshold and optionally the time interval for rekeying. Use values appropriate for the server version.

Example
RekeyLimit 1G 1h
Ciphers

Select permitted encryption algorithms. Replacing the default list may reduce compatibility; use ssh -Q cipher to inspect client-supported algorithms.

Example
Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com
KexAlgorithms

Select key exchange algorithms. Restricting this list can break clients; verify support on both sides.

Example
KexAlgorithms curve25519-sha256
PubkeyAcceptedAlgorithms

Select permitted public-key signature algorithms for user authentication. Verify compatibility before changing the default list.

Example
PubkeyAcceptedAlgorithms ssh-ed25519
HostKeyAlgorithms

Select host-key signature algorithms offered by the server. The configured host key must support the chosen algorithm.

Example
HostKeyAlgorithms ssh-ed25519
TrustedUserCAKeys

File containing trusted user certificate authority public keys for certificate authentication.

Example
TrustedUserCAKeys /etc/ssh/user_ca.pub
RevokedKeys

File containing revoked public keys or a key revocation list. A missing or unreadable configured file can prevent public-key authentication.

Example
RevokedKeys /etc/ssh/revoked_keys
AuthorizedPrincipalsFile

File listing principals permitted for a user certificate signed by a trusted CA; token expansion is supported.

Example
AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u
VersionAddendum

Append text to the SSH protocol banner; none disables the added text.

Example
VersionAddendum none
AuthorizedKeysCommand

Run a trusted, root-owned program to obtain public keys. Configure its execution account and follow the manual's ownership requirements.

Example
AuthorizedKeysCommand /usr/local/libexec/ssh-keys %u
AuthorizedKeysCommandUser

Account used to run AuthorizedKeysCommand; a dedicated account is recommended.

Example
AuthorizedKeysCommandUser sshkeys
AuthorizedPrincipalsCommand

Run a trusted program to obtain permitted certificate principals. Configure its execution account separately.

Example
AuthorizedPrincipalsCommand /usr/local/libexec/ssh-principals %u
AuthorizedPrincipalsCommandUser

Account used to run AuthorizedPrincipalsCommand; use a dedicated account.

Example
AuthorizedPrincipalsCommandUser sshprincipals
CASignatureAlgorithms

Restrict certificate authority signature algorithms accepted for SSH certificates. Verify CA and client compatibility before changes.

Example
CASignatureAlgorithms ssh-ed25519
ChannelTimeout

Expire inactive channels by channel type and duration; availability and supported channel types depend on version. Expiry need not terminate the SSH connection.

Example
ChannelTimeout session=1h
ExposeAuthInfo

Expose authentication information through a temporary file referenced by SSH_USER_AUTH; consider access to authentication details.

Example
ExposeAuthInfo no
FingerprintHash

Select the hash used for key fingerprints, such as sha256 or md5. Prefer SHA-256.

Example
FingerprintHash sha256
GSSAPIAuthentication

Control GSSAPI user authentication when supported by the server build.

Example
GSSAPIAuthentication no
GSSAPICleanupCredentials

Control whether delegated GSSAPI credentials are destroyed at logout; build support varies.

Example
GSSAPICleanupCredentials yes
GSSAPIDelegateCredentials

Control storing delegated GSSAPI credentials for user sessions when supported.

Example
GSSAPIDelegateCredentials no
GSSAPIStrictAcceptorCheck

Control whether the server requires the correct GSSAPI host identity. Disabling verification has security implications.

Example
GSSAPIStrictAcceptorCheck yes
HostbasedAcceptedAlgorithms

Select algorithms accepted for host-based authentication. Availability varies by OpenSSH version.

Example
HostbasedAcceptedAlgorithms ssh-ed25519
HostbasedAuthentication

Control host-based authentication; it requires additional trust and host configuration.

Example
HostbasedAuthentication no
HostbasedUsesNameFromPacketOnly

Control whether host-based authentication uses the name supplied by the client instead of DNS. Review the trust implications.

Example
HostbasedUsesNameFromPacketOnly no
HostKeyAgent

Specify the agent socket used to access host private keys. The agent and its socket must be available to sshd.

Example
HostKeyAgent /run/ssh-hostkey-agent.sock
IgnoreRhosts

Control use of per-user rhosts or shosts files for host-based authentication; accepted values vary by version.

Example
IgnoreRhosts yes
IgnoreUserKnownHosts

Control whether user-specific known_hosts files are ignored during host-based authentication.

Example
IgnoreUserKnownHosts yes
KerberosAuthentication

Control Kerberos password authentication when built and configured with Kerberos support.

Example
KerberosAuthentication no
KerberosGetAFSToken

Control obtaining an AFS token for a Kerberos-authenticated user where the build supports it.

Example
KerberosGetAFSToken no
KerberosOrLocalPasswd

Control whether failed Kerberos password validation falls back to local password authentication.

Example
KerberosOrLocalPasswd no
KerberosTicketCleanup

Control removal of a user's Kerberos ticket cache at logout where supported.

Example
KerberosTicketCleanup yes
LogVerbose

Override logging verbosity for matching source locations. It is intended for troubleshooting and may expose sensitive information.

Example
LogVerbose kex.c:*:1000
ModuliFile

Path to the moduli file used for Diffie-Hellman group exchange; maintain it according to platform guidance.

Example
ModuliFile /etc/ssh/moduli
PAMServiceName

Select the PAM service name on builds that support this directive; PAM policy for the selected service must exist.

Example
PAMServiceName sshd
PermitTunnel

Control tun device forwarding: yes, point-to-point, ethernet, or no. Additional system privileges and configuration may be required.

Example
PermitTunnel no
PermitUserRC

Control execution of the user's SSH rc file. Disabling it can affect user session setup.

Example
PermitUserRC no
PerSourceMaxStartups

Limit simultaneous unauthenticated connections per source address or source group; version support varies.

Example
PerSourceMaxStartups 10
PerSourceNetBlockSize

Set IPv4 and IPv6 prefix lengths used to group sources for per-source connection limits.

Example
PerSourceNetBlockSize 32:128
PerSourcePenalties

Configure penalties for problematic sources. Supported penalty types, values, and defaults vary by OpenSSH version.

Example
PerSourcePenalties no
PerSourcePenaltyExemptList

List source addresses or CIDR ranges exempt from per-source penalties; ensure exemptions are narrowly scoped.

Example
PerSourcePenaltyExemptList 192.0.2.0/24
PidFile

Path to the server process ID file. Ensure the service manager and permissions agree with this path.

Example
PidFile /run/sshd.pid
PrintLastLog

Control printing the previous login time for interactive logins. Availability may depend on platform support.

Example
PrintLastLog yes
PubkeyAuthOptions

Set public-key authentication options, including security-key touch or verification requirements when supported.

Example
PubkeyAuthOptions touch-required
RefuseConnection

Refuse a connection, typically inside a Match block. Availability varies by version.

Example
Match User blocked
    RefuseConnection yes
RequiredRSASize

Set the minimum RSA key size accepted by sshd. Lower values may weaken security and some versions impose a minimum.

Example
RequiredRSASize 3072
RDomain

Select a routing domain for the session on platforms that support routing domains. This is platform-specific.

Example
RDomain 1
SecurityKeyProvider

Path to a FIDO security-key middleware library; leaving it unset uses the built-in support where available.

Example
SecurityKeyProvider /usr/local/lib/libsk-libfido2.so
SshdAuthPath

Path to the sshd authentication helper on versions and platforms that support it. Normally managed by the package.

Example
SshdAuthPath /usr/libexec/sshd-auth
SshdSessionPath

Path to the sshd session helper on versions and platforms that support it. Normally managed by the package.

Example
SshdSessionPath /usr/libexec/sshd-session
StreamLocalBindMask

Set the octal file mode creation mask for a Unix-domain forwarding socket.

Example
StreamLocalBindMask 0177
StreamLocalBindUnlink

Control whether an existing Unix-domain socket is removed before creating a forwarding listener.

Example
StreamLocalBindUnlink no
UnusedConnectionTimeout

Close connections with no open channels after the specified time. Affected behavior and availability vary by version.

Example
UnusedConnectionTimeout 5m
X11DisplayOffset

Set the first display number available for X11 forwarding.

Example
X11DisplayOffset 10
X11UseLocalhost

Bind the X11 forwarding server to loopback when enabled; disabling it can expose the display more widely.

Example
X11UseLocalhost yes
XAuthLocation

Path to the xauth program used for X11 forwarding where applicable.

Example
XAuthLocation /usr/bin/xauth
IPQoS

Set IP quality-of-service markings for interactive and non-interactive sessions. Network devices may interpret or ignore these markings.

Example
IPQoS lowdelay throughput
MACs

Select message authentication code algorithms. Changing the defaults can affect security and client compatibility.

Example
MACs hmac-sha2-256-etm@openssh.com
SetEnv

Set environment variables for child sessions. These values override variables accepted from clients or user environment files.

Example
SetEnv LANG=en_US.UTF-8
UseDNS

Control reverse DNS lookup and verification for connecting clients. Enabling it may add delay if DNS is slow.

Example
UseDNS no

Recommended Starting Configuration

For a server with verified public-key login and no keyboard-interactive authentication requirement. TCP forwarding remains enabled for authenticated users; remote forwarded listeners bind to loopback.

PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin no
PermitEmptyPasswords no
AllowTcpForwarding yes
GatewayPorts no

This disables password and keyboard-interactive login, which may include PAM or one-time codes. Confirm another administrator account and its key work first. AllowTcpForwarding yes permits forwarding for authenticated users; restrict access where appropriate. Adapt the policy to your needs.

Keep your current session and a recovery method available. Merge these settings into the existing configuration rather than blindly appending: Include ordering, earlier values and Match blocks may override them. Run sshd -t, inspect sshd -T (and sshd -T -C for relevant Match conditions), then apply using your system’s service procedure and verify a second login before disconnecting.

Authoritative references

Reviewed October 27, 2026