SSHD_CONFIG(5)

๐ŸŽ€ sshd_config ๐ŸŽ€

โœจ NAME โœจ

sshd_config โ€” the OpenSSH daemon configuration file ๐Ÿ’– (yes bestie, this is sshd_config(5), File Formats Manual, we are literally in it)


๐ŸŒธ DESCRIPTION ๐ŸŒธ

So sshd(8) reads its configuration data from /etc/ssh/sshd_config โ€” or from whatever file you point it at with -f on the command line, your call ๐Ÿซถ.

The file is made of keywordโ€“argument pairs, one per line. And here's the vibe check: unless the page says otherwise, for each keyword the first obtained value is the one that gets used. First one wins, periodt ๐Ÿ’….

Lines starting with # and empty lines are comments (so go ahead and leave yourself little love notes in there, they're free โœจ). Arguments can optionally be wrapped in double quotes (") so you can represent arguments that contain spaces. Iconic.

๐Ÿ“Œ Note that the Debian openssh-server package ships several options as standard in /etc/ssh/sshd_config that are not the default in sshd(8):
  • Include /etc/ssh/sshd_config.d/*.conf
  • KbdInteractiveAuthentication no
  • X11Forwarding yes
  • PrintMotd no
  • AcceptEnv LANG LC_* COLORTERM NO_COLOR
  • Subsystem sftp /usr/lib/openssh/sftp-server
  • UsePAM yes

The /etc/ssh/sshd_config.d/*.conf files get pulled in at the start of the configuration file, so anything you set in there will override the stuff in /etc/ssh/sshd_config. Sneaky but make it fashion ๐Ÿ’….

The possible keywords and their meanings are as follows โ€” and quick heads-up: keywords are case-insensitive but arguments are case-sensitive ๐Ÿ‘‘


๐Ÿฆ‹ AcceptEnv

Specifies which environment variables sent by the client get copied into the session's environ(7). Wanna know how to set it up on the client side? See SendEnv and SetEnv in ssh_config(5), bestie.

The TERM environment variable is always accepted whenever the client requests a pseudo-terminal, because the protocol literally requires it. Not negotiable.

Variables are specified by name, and names may contain the wildcard characters * and ?. Multiple environment variables can be separated by whitespace, or spread across multiple AcceptEnv directives โ€” do whatever's cute โœจ.

โš ๏ธ Be warned: some environment variables could be used to bypass restricted user environments. For this reason, care should be taken in the use of this directive. That's a real warning, not a vibe.

The default is not to accept any environment variables. None. Zero. Nada.

๐ŸŒˆ AddressFamily

Specifies which address family sshd(8) should use. Valid arguments are any (the default), inet (IPv4 only), or inet6 (IPv6 only). Pick your fighter ๐ŸฅŠ.

๐Ÿ’œ AllowAgentForwarding

Specifies whether ssh-agent(1) forwarding is permitted. Default is yes.

๐Ÿ“Œ Note that disabling agent forwarding does not improve security unless users are also denied shell access โ€” because they can always install their own forwarders. So likeโ€ฆ do both or don't bother, iykyk ๐Ÿ˜ญ.

๐Ÿ“ AllowGroups

This keyword can be followed by a list of group name patterns, separated by spaces. If specified, login is allowed only for users whose primary group or supplementary group list matches one of the patterns.

Only group names are valid โ€” a numerical group ID is not recognized ๐Ÿ™ˆ. By default, login is allowed for all groups.

AllowGroups is not consulted for groups matched by DenyGroups.

See PATTERNS in ssh_config(5) for more information on patterns. This keyword may appear multiple times in sshd_config, with each instance appending to the list โ€” collect them all โœจ.

๐Ÿงš AllowStreamLocalForwarding

Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted. The available options are:

  • yes (the default) or all โ€” allow StreamLocal forwarding
  • no โ€” prevent all StreamLocal forwarding
  • local โ€” allow local (from the perspective of ssh(1)) forwarding only
  • remote โ€” allow remote forwarding only
๐Ÿ“Œ Note that disabling StreamLocal forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders. Same lore as above, we been knew ๐Ÿ’€.

โญ AllowTcpForwarding

Specifies whether TCP forwarding is permitted. The available options are:

  • yes (the default) or all โ€” allow TCP forwarding
  • no โ€” prevent all TCP forwarding
  • local โ€” allow local (from the perspective of ssh(1)) forwarding only
  • remote โ€” allow remote forwarding only
๐Ÿ“Œ Note that disabling TCP forwarding does not improve security unless users are also denied shell access, as they can always install their own forwarders. (Yes this is the third time, it's that important ๐Ÿซ .)

๐Ÿ’– AllowUsers

This keyword can be followed by a list of user name patterns, separated by spaces. If specified, login is allowed only for user names that match one of the patterns.

Only user names are valid โ€” a numerical user ID is not recognized. By default, login is allowed for all users.

If the pattern takes the form USER@HOST then USER and HOST are checked separately, restricting logins to particular users from particular hosts. And HOST criteria may additionally contain addresses to match in CIDR address/masklen</> format. Fancy.

AllowUsers is not consulted for users matched by DenyUsers.

See PATTERNS in ssh_config(5) for more information on patterns. This keyword may appear multiple times in sshd_config with each instance appending to the list ๐Ÿ‘‘.

๐ŸŽ€ AuthenticationMethods

Specifies the authentication methods that must be successfully completed for a user to be granted access. This option must be followed by one or more lists of comma-separated authentication method names, or by the single string any to indicate the default behaviour of accepting any single authentication method.

If the default is overridden, then successful authentication requires completion of every method in at least one of these lists. Multi-step queen behavior ๐Ÿ’….

For example, "publickey,password publickey,keyboard-interactive" would require the user to complete public key authentication, followed by either password or keyboard interactive authentication.

Only methods that are next in one or more lists are offered at each stage, so for this example it would not be possible to attempt password or keyboard-interactive authentication before public key. Order matters, bestie.

For keyboard interactive authentication it is also possible to restrict authentication to a specific device by appending a colon followed by the device identifier bsdauth or pam. depending on the server configuration. For example, "keyboard-interactive:bsdauth" would restrict keyboard interactive authentication to the bsdauth device.

If the publickey method is listed more than once, sshd(8) verifies that keys that have been used successfully are not reused for subsequent authentications. For example, "publickey,publickey" requires successful authentication using two different public keys. Two keys, no copy-paste energy ๐Ÿ™ˆ.

๐Ÿ“Œ Note that each authentication method listed should also be explicitly enabled in the configuration.

The available authentication methods are: "gssapi-with-mic", "hostbased", "keyboard-interactive", "none" (used for access to password-less accounts when PermitEmptyPasswords is enabled), "password" and "publickey".

๐Ÿฆ‹ AuthorizedKeysCommand

Specifies a program to be used to look up the user's public keys. The program must be owned by root, not writable by group or others, and specified by an absolute path. Arguments to AuthorizedKeysCommand accept the tokens described in the โ€œTOKENSโ€ section. If no arguments are specified then the username of the target user is used.

The program should produce on standard output zero or more lines of authorized_keys output (see AUTHORIZED_KEYS in sshd(8)).

AuthorizedKeysCommand is tried after the usual AuthorizedKeysFile files and will not be executed if a matching key is found there. By default, no AuthorizedKeysCommand is run. This command is only executed for valid users.

๐Ÿ’œ AuthorizedKeysCommandUser

Specifies the user under whose account the AuthorizedKeysCommand is run. It's recommended to use a dedicated user that has no other role on the host than running authorized keys commands โ€” like, give them one job and let them slay it ๐Ÿ’….

โš ๏ธ If AuthorizedKeysCommand is specified but AuthorizedKeysCommandUser is not, then sshd(8) will refuse to start. Yes, actually refuse. No cap.

๐Ÿ“ AuthorizedKeysFile

Specifies the file that contains the public keys used for user authentication. The format is described in the AUTHORIZED_KEYS FILE FORMAT section of sshd(8).

Arguments to AuthorizedKeysFile may include wildcards and accept the tokens described in the โ€œTOKENSโ€ section. After expansion, AuthorizedKeysFile is taken to be an absolute path or one relative to the user's home directory. Multiple files may be listed, separated by whitespace. Alternately this option may be set to none to skip checking for user keys in files.

The default is ".ssh/authorized_keys .ssh/authorized_keys2". These files are only checked for valid users โœจ.

๐ŸŒˆ AuthorizedPrincipalsCommand

Specifies a program to be used to generate the list of allowed certificate principals as per AuthorizedPrincipalsFile. The program must be owned by root, not writable by group or others, and specified by an absolute path. Arguments to AuthorizedPrincipalsCommand accept the tokens described in the โ€œTOKENSโ€ section. If no arguments are specified then the username of the target user is used.

The program should produce on standard output zero or more lines of AuthorizedPrincipalsFile output.

If either AuthorizedPrincipalsCommand or AuthorizedPrincipalsFile is specified, then certificates offered by the client for authentication must contain a principal that is listed. By default, no AuthorizedPrincipalsCommand is run. This command is only executed for valid users.

๐Ÿงš AuthorizedPrincipalsCommandUser

Specifies the user under whose account the AuthorizedPrincipalsCommand is run. It is recommended to use a dedicated user that has no other role on the host than running authorized principals commands โ€” one job, one slay ๐Ÿซถ.

โš ๏ธ If AuthorizedPrincipalsCommand is specified but AuthorizedPrincipalsCommandUser is not, then sshd(8) will refuse to start. Same energy as above, still very much real.

Okay bestie, that's the first chunk โ€” more keywords are coming, so stay tuned and don't touch anything yet ๐Ÿ˜Œ๐Ÿ’–

๐Ÿ’– AuthorizedPrincipalsFile ๐Ÿ’–

Okay so this one is basically the VIP list for certificate auth, bestie. It specifies a file that lists principal names accepted for certificate authentication. When you're using certificates signed by a key listed in TrustedUserCAKeys, this file lists names โ€” and one of them must appear in the certificate for it to be accepted for authentication. Names are listed one per line, preceded by key options (as described in AUTHORIZED_KEYS FILE FORMAT in sshd(8)). Empty lines and comments starting with # are ignored. ๐Ÿซถ

Arguments to AuthorizedPrincipalsFile may include wildcards and accept the tokens described in the โ€œTOKENSโ€ section. After expansion, AuthorizedPrincipalsFile is taken to be an absolute path or one relative to the user's home directory. The default is none, i.e. not to use a principals file โ€” in this case, the username of the user must appear in a certificate's principals list for it to be accepted. This file is only checked for valid users. โœจ

Note that AuthorizedPrincipalsFile is only used when authentication proceeds using a CA listed in TrustedUserCAKeys and is not consulted for certification authorities trusted via ~/.ssh/authorized_keys, though the principals= key option offers a similar facility (see sshd(8) for details). ๐Ÿ’…

The contents of the specified file are sent to the remote user before authentication is allowed. If the argument is none then no banner is displayed. By default, no banner is displayed. Simple as that, no cap. ๐ŸŒธ


๐Ÿฆ‹ CASignatureAlgorithms ๐Ÿฆ‹

Specifies which algorithms are allowed for signing of certificates by certificate authorities (CAs). The default is:

ssh-ed25519,ecdsa-sha2-nistp256,
ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
sk-ssh-ed25519@openssh.com,
sk-ecdsa-sha2-nistp256@openssh.com,
rsa-sha2-512,rsa-sha2-256,
ssh-mldsa44-ed25519@openssh.com

If the specified list begins with a + character, then the specified algorithms will be appended to the default set instead of replacing them. If the specified list begins with a - character, then the specified algorithms (including wildcards) will be removed from the default set instead of replacing them. ๐Ÿ‘‘

Certificates signed using other algorithms will not be accepted for public key or host-based authentication. Periodt.


๐ŸŒˆ ChannelTimeout ๐ŸŒˆ

Specifies whether and how quickly sshd(8) should close inactive channels. Timeouts are specified as one or more type=interval pairs separated by whitespace, where the type must be the special keyword global or a channel type name from the list below, optionally containing wildcard characters. ๐Ÿงš

The timeout value interval is specified in seconds or may use any of the units documented in the โ€œTIME FORMATSโ€ section. For example, session=5m would cause interactive sessions to terminate after five minutes of inactivity. Specifying a zero value disables the inactivity timeout. ๐Ÿ’–

The special timeout global applies to all active channels, taken together. Traffic on any active channel will reset the timeout, but when the timeout expires then all open channels will be closed. Note that this global timeout is not matched by wildcards and must be specified explicitly. โญ

The available channel type names include:

  • agent-connection โ€” Open connections to ssh-agent(1).
  • direct-tcpip, direct-streamlocal@openssh.com โ€” Open TCP or Unix socket (respectively) connections that have been established from an ssh(1) local forwarding, i.e. LocalForward or DynamicForward.
  • forwarded-tcpip, forwarded-streamlocal@openssh.com โ€” Open TCP or Unix socket (respectively) connections that have been established to an sshd(8) listening on behalf of an ssh(1) remote forwarding, i.e. RemoteForward.
  • session โ€” The interactive main session, including shell session, command execution, scp(1), sftp(1), etc.
  • tun-connection โ€” Open TunnelForward connections.
  • x11-connection โ€” Open X11 forwarding sessions.

Note that in all the above cases, terminating an inactive session does not guarantee to remove all resources associated with the session, e.g. shell processes or X11 clients relating to the session may continue to execute. ๐Ÿ˜ญ

Moreover, terminating an inactive channel or session does not necessarily close the SSH connection, nor does it prevent a client from requesting another channel of the same type. In particular, expiring an inactive forwarding session does not prevent another identical forwarding from being subsequently created. ๐Ÿ™ˆ

The default is not to expire channels of any type for inactivity.


๐Ÿ’œ ChrootDirectory ๐Ÿ’œ

Specifies the pathname of a directory to chroot(2) to after authentication. At session startup sshd(8) checks that all components of the pathname are root-owned directories which are not writable by group or others. After the chroot, sshd(8) changes the working directory to the user's home directory. Arguments to ChrootDirectory accept the tokens described in the โ€œTOKENSโ€ section. ๐Ÿซถ

The ChrootDirectory must contain the necessary files and directories to support the user's session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), and tty(4) devices. For file transfer sessions using SFTP no additional configuration of the environment is necessary if the in-process sftp-server is used, though sessions which use logging may require /dev/log inside the chroot directory on some operating systems (see sftp-server(8) for details). ๐ŸŽ€

For safety, it is very important that the directory hierarchy be prevented from modification by other processes on the system (especially those outside the jail). Misconfiguration can lead to unsafe environments which sshd(8) cannot detect. ๐Ÿ’€

The default is none, indicating not to chroot(2).


๐Ÿ”ฅ Ciphers ๐Ÿ”ฅ

Specifies the ciphers allowed. Multiple ciphers must be comma-separated. If the specified list begins with a + character, then the specified ciphers will be appended to the default set instead of replacing them. If the specified list begins with a - character, then the specified ciphers (including wildcards) will be removed from the default set instead of replacing them. If the specified list begins with a ^ character, then the specified ciphers will be placed at the head of the default set. ๐Ÿ‘‘

The supported ciphers are:

3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
chacha20-poly1305@openssh.com

The default is:

chacha20-poly1305@openssh.com,
aes128-gcm@openssh.com,aes256-gcm@openssh.com,
aes128-ctr,aes192-ctr,aes256-ctr

The list of available ciphers may also be obtained using ssh -Q cipher. โœจ


๐Ÿ“ ClientAliveCountMax ๐Ÿ“

Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. ๐Ÿฆ‹

The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination. ๐Ÿ’…


๐ŸŒธ ClientAliveInterval ๐ŸŒธ

Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. ๐ŸŽ€


๐Ÿ‘‘ Compression ๐Ÿ‘‘

Specifies whether compression is enabled after the user has authenticated successfully. The argument must be yes, delayed (a legacy synonym for yes) or no. The default is yes. โœจ

Compression applies to all traffic that flows over the SSH connection. If untrusted traffic (such as an open port-forward) is permitted over the connection alongside trusted traffic, then compression may leak information about session contents. For this reason, it is not recommended to enable compression for connections that share trusted and untrusted traffic. ๐Ÿ˜ญ


๐ŸŒŸ DebianBanner ๐ŸŒŸ

Specifies whether the distribution-specified extra version suffix is included during initial protocol handshake. The default is yes. ๐Ÿซถ


๐Ÿ’€ DenyGroups ๐Ÿ’€

This keyword can be followed by a list of group name patterns, separated by spaces. Login is disallowed for users whose primary group or supplementary group list matches one of the patterns. Only group names are valid; a numerical group ID is not recognized. By default, login is allowed for all groups. AllowGroups is not consulted for groups matched by DenyGroups. ๐Ÿ™ˆ

See PATTERNS in ssh_config(5) for more information on patterns. This keyword may appear multiple times in sshd_config with each instance appending to the list. ๐Ÿ’…

DenyUsers

Okay so bestie, this one is the block list ๐Ÿ’… โ€” you put a bunch of user name patterns after the keyword, separated by spaces, and login is disallowed for any user name that matches one of them.

Heads up: only user names are valid here. A numerical user ID? Not recognized. Nope. ๐Ÿ™ˆ

By default, login is allowed for all users. But if a pattern takes the form USER@HOST, then USER and HOST get checked separately, which restricts logins to particular users coming from particular hosts. And HOST criteria may additionally contain addresses to match in CIDR address/masklen format โ€” fancy, I know โœจ

Also lowkey important: AllowUsers is not consulted for users matched by DenyUsers. So don't be out here thinking AllowUsers will save you.

Peep PATTERNS in ssh_config(5) for more on patterns. And this keyword may appear multiple times in sshd_config, with each instance appending to the list โ€” it's giving collect-them-all ๐ŸŽ€

DisableForwarding

This one just turns everything forwarding off, no cap: X11, ssh-agent(1), TCP and StreamLocal. All of it. ๐Ÿšซ

It overrides all other forwarding-related options, which honestly may simplify your restricted configurations โ€” one flag to rule them all, periodt ๐Ÿ‘‘

ExposeAuthInfo

Writes a temporary file containing a list of authentication methods and public credentials (e.g. keys) used to authenticate the user ๐Ÿ‘€ The location of that file gets exposed to the user session through the SSH_USER_AUTH environment variable โ€” iykyk.

Default is no.

FingerprintHash

Specifies the hash algorithm used when logging key fingerprints. Valid options are: md5 and sha256. Default is sha256 โ€” we stay modern around here ๐Ÿ’…โœจ

ForceCommand

Forces the execution of the command specified by ForceCommand, ignoring any command supplied by the client and ~/.ssh/rc if present. Rude? Maybe. Iconic? Absolutely ๐Ÿ‘‘

The command is invoked by using the user's login shell with the -c option. This applies to shell, command, or subsystem execution. It's most useful inside a Match block. And the command the client originally supplied is still available in the SSH_ORIGINAL_COMMAND environment variable โ€” so you can peek at what they wanted ๐Ÿ™ˆ

Specifying a command of internal-sftp will force the use of an in-process SFTP server that requires no support files when used with ChrootDirectory. The default is none.

๐Ÿ’€ Real talk warning: this directive does not limit other kinds of access that a client may request via their connection โ€” such as TCP, agent, socket or X11 forwarding. If you don't want those, you have to explicitly disable them, either individually via their respective options or all together using the DisableForwarding option. Don't get caught out, bestie.

GatewayPorts

Specifies whether remote hosts are allowed to connect to ports forwarded for the client. By default, sshd(8) binds remote port forwardings to the loopback address ๐Ÿ“ โ€” which prevents other remote hosts from connecting to forwarded ports. Makes sense, keeps things cozy.

GatewayPorts can be used to say "actually sshd, allow remote port forwardings to bind to non-loopback addresses", thus letting other hosts connect. The argument may be:

  • no โ€” force remote port forwardings to be available to the local host only
  • yes โ€” force remote port forwardings to bind to the wildcard address
  • clientspecified โ€” let the client select the address to which the forwarding is bound ๐Ÿ™ˆ

The default is no.

GSSAPIAuthentication

Specifies whether user authentication based on GSSAPI is allowed. The default is no.

GSSAPICleanupCredentials

Specifies whether to automatically destroy the user's credentials cache on logout. The default is yes โ€” clean girl behaviour ๐Ÿงนโœจ

GSSAPIDelegateCredentials

Accept delegated credentials on the server side. The default is yes.

GSSAPIStrictAcceptorCheck

Determines whether to be strict about the identity of the GSSAPI acceptor a client authenticates against. If set to yes then the client must authenticate against the host service on the current hostname ๐ŸŽฏ If set to no then the client may authenticate against any service key stored in the machine's default store.

This facility is provided to assist with operation on multi homed machines. The default is yes.

This option may not be effective in Windows Active Directory environments. Just so you know ๐Ÿ’€

HostbasedAcceptedAlgorithms

Specifies the signature algorithms that will be accepted for hostbased authentication, as a list of comma-separated patterns. Now here's the little cheat code system:

  • if the specified list begins with a + character, then the specified signature algorithms will be appended to the default set instead of replacing them
  • if it begins with a - character, then the specified signature algorithms (including wildcards!) will be removed from the default set instead of replacing them
  • if it begins with a ^ character, then the specified signature algorithms will be placed at the head of the default set

The default for this option is:

   ssh-ed25519-cert-v01@openssh.com,
   ecdsa-sha2-nistp256-cert-v01@openssh.com,
   ecdsa-sha2-nistp384-cert-v01@openssh.com,
   ecdsa-sha2-nistp521-cert-v01@openssh.com,
   sk-ssh-ed25519-cert-v01@openssh.com,
   sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
   webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
   rsa-sha2-512-cert-v01@openssh.com,
   rsa-sha2-256-cert-v01@openssh.com,
   ssh-mldsa44-ed25519-cert-v01@openssh.com,
   ssh-ed25519,
   ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
   sk-ssh-ed25519@openssh.com,
   sk-ecdsa-sha2-nistp256@openssh.com,
   webauthn-sk-ecdsa-sha2-nistp256@openssh.com,
   rsa-sha2-512,rsa-sha2-256,
   ssh-mldsa44-ed25519@openssh.com

The list of available signature algorithms may also be obtained using ssh -Q HostbasedAcceptedAlgorithms โ€” go try it, it's satisfying ๐ŸŒˆ

This was formerly named HostbasedAcceptedKeyTypes.

HostbasedAuthentication

Specifies whether rhosts or /etc/hosts.equiv authentication together with successful public key client host authentication is allowed (host-based authentication). The default is no.

HostbasedUsesNameFromPacketOnly

Specifies whether or not the server will attempt to perform a reverse name lookup when matching the name in the ~/.shosts, ~/.rhosts, and /etc/hosts.equiv files during HostbasedAuthentication.

A setting of yes means that sshd(8) uses the name supplied by the client rather than attempting to resolve the name from the TCP connection itself โ€” trust the client, bestie ๐Ÿซถ The default is no.

HostCertificate

Specifies a file containing a public host certificate. The certificate's public key must match a private host key already specified by HostKey ๐Ÿ”‘ The default behaviour of sshd(8) is not to load any certificates.

HostKey

Specifies a file containing a private host key used by SSH. The defaults are /etc/ssh/ssh_host_ecdsa_key, /etc/ssh/ssh_host_ed25519_key, /etc/ssh/ssh_host_mldsa44_ed25519_key and /etc/ssh/ssh_host_rsa_key.

Note that sshd(8) will refuse to use a file if it is group/world-accessible ๐Ÿ’€ and that the HostKeyAlgorithms option restricts which of the keys are actually used by sshd(8).

It is possible to have multiple host key files โ€” more is more, okay? โœจ It is also possible to specify public host key files instead. In this case operations on the private key will be delegated to an ssh-agent(1). Delegation! Main character energy ๐Ÿ‘‘

HostKeyAgent

Identifies the UNIX-domain socket used to communicate with an agent that has access to the private host keys ๐Ÿ”Œ If the string "SSH_AUTH_SOCK" is specified, the location of the socket will be read from the SSH_AUTH_SOCK environment variable.

HostKeyAlgorithms

Specifies the host key signature algorithms that the server offers. The default for this option is:

   ssh-ed25519-cert-v01@openssh.com,
   ecdsa-sha2-nistp256-cert-v01@openssh.com,
   ecdsa-sha2-nistp384-cert-v01@openssh.com,
   ecdsa-sha2-nistp521-cert-v01@openssh.com,
   sk-ssh-ed25519-cert-v01@openssh.com,
   sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
   webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
   rsa-sha2-512-cert-v01@openssh.com,
   rsa-sha2-256-cert-v01@openssh.com,
   ssh-mldsa44-ed25519-cert-v01@openssh.com,
   ssh-ed25519,
   ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
   sk-ssh-ed25519@openssh.com,
   sk-ecdsa-sha2-nistp256@openssh.com,
   webauthn-sk-ecdsa-sha2-nistp256@openssh.com,
   rsa-sha2-512,rsa-sha2-256,
   ssh-mldsa44-ed25519@openssh.com

The list of available signature algorithms may also be obtained using ssh -Q HostKeyAlgorithms ๐Ÿ’–

IgnoreRhosts

Specifies whether to ignore per-user .rhosts and .shosts files during HostbasedAuthentication. The system-wide /etc/hosts.equiv and /etc/ssh/shosts.equiv are still used regardless of this setting โ€” those ones stay no matter what, periodt.

Accepted values are:

  • yes (the default) โ€” ignore all per-user files
  • shosts-only โ€” allow the use of .shosts but ignore .rhosts
  • no โ€” allow both .shosts and rhosts

IgnoreUserKnownHosts

Specifies whether sshd(8) should ignore the user's ~/.ssh/known_hosts during HostbasedAuthentication and use only the system-wide known hosts file /etc/ssh/ssh_known_hosts. The default is "no". ๐Ÿ™ˆ

Include

Include the specified configuration file(s) ๐Ÿ“‚ Multiple pathnames may be specified and each pathname may contain glob(7) wildcards that will be expanded and processed in lexical order โ€” alphabetical besties, stay in line ๐Ÿ’…

Files without absolute paths are assumed to be in /etc/ssh. An Include directive may appear inside a Match block to perform conditional inclusion โ€” nesting! we love to see it ๐Ÿฆ‹

  • IPQoS โ€” sets the Differentiated Services Field Codepoint (DSCP) value for the connection ๐Ÿ’… accepted values are af11, af12, af13, af21, af22, af23, af31, af32, af33, af41, af42, af43, cs0, cs1, cs2, cs3, cs4, cs5, cs6, cs7, ef, le, a numeric value, or none to just use whatever the operating system defaults to. It's a flexible little icon and can take one or two arguments, separated by whitespace. One arg? That's your packet class, unconditional, no cap. Two args? Bestie, the first gets auto-picked for interactive sessions and the second for non-interactive ones. Default is ef (Expedited Forwarding) for interactive sessions and none (the OS default) for non-interactive sessions. slay โœจ
  • KbdInteractiveAuthentication โ€” do we allow keyboard-interactive authentication or not? Default is yes, and the argument has to be literally yes or no. Also, FYI, ChallengeResponseAuthentication is a deprecated alias for this one โ€” it's giving legacy, don't @ me ๐Ÿ’€
  • KerberosAuthentication โ€” should the password the user hands over for PasswordAuthentication get validated through the Kerberos KDC? If you want this, the server needs a Kerberos servtab that allows verification of the KDC's identity. Default is no ๐Ÿ™ˆ
  • KerberosGetAFSToken โ€” if AFS is active and the user has a Kerberos 5 TGT, try to grab an AFS token before touching the user's home directory. Default is no ๐ŸŽ€
  • KerberosOrLocalPasswd โ€” if password auth through Kerberos flops, the password gets validated via any additional local mechanism like /etc/passwd. Default is yes โ€” backup plan energy fr fr ๐Ÿซถ
  • KerberosTicketCleanup โ€” do we automatically destroy the user's ticket cache file on logout? Default is yes. Cleanup queen ๐Ÿงนโœจ
  • KexAlgorithms โ€” the permitted KEX (Key Exchange) algorithms the server will offer to clients. Important vibe check: the ordering of this list does not matter, because the client specifies the preference order. Multiple algorithms must be comma-separated.

Prefix magic, and yes it's iconic:

  • starts with a +? then the specified algorithms get appended to the default set instead of replacing them ๐Ÿ’–
  • starts with a -? then the specified algorithms (wildcards included) get removed from the default set instead of replacing them โœ‚๏ธ
  • starts with a ^? then the specified algorithms get placed at the head of the default set ๐Ÿ‘‘

The supported algorithms are:

curve25519-sha256
curve25519-sha256@libssh.org
diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group14-sha256
diffie-hellman-group16-sha512
diffie-hellman-group18-sha512
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
mlkem768nistp256-sha256
mlkem768x25519-sha256
sntrup761x25519-sha512
sntrup761x25519-sha512@openssh.com

The default is:

mlkem768x25519-sha256,
sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com,
curve25519-sha256,curve25519-sha256@libssh.org,
ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521

You can also just pull the list of supported key exchange algorithms with "ssh -Q KexAlgorithms" ๐Ÿ’…

  • ListenAddress โ€” the local addresses sshd(8) should listen on. The following forms may be used:
ListenAddress hostname|address [rdomain domain]
ListenAddress hostname:port [rdomain domain]
ListenAddress IPv4_address:port [rdomain domain]
ListenAddress [hostname|address]:port [rdomain domain]

That optional rdomain qualifier asks sshd(8) to listen in an explicit routing domain. If port isn't specified, sshd listens on the address and all Port options you set. Default is to listen on all local addresses on the current default routing domain. Multiple ListenAddress options are permitted โ€” stack 'em, bestie ๐ŸŒธ

On Linux, routing domains are implemented using Virtual Routing and Forwarding domains (VRFs); for more information, see ip-vrf(8). iykyk
  • LoginGraceTime โ€” the server disconnects after this much time if the user hasn't successfully logged in. If the value is 0, there's no time limit at all (chaotic, but okay ๐Ÿ’€). Default is 120 seconds โณ
  • LogLevel โ€” the verbosity level used when logging messages from sshd(8). Possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. Default is INFO. DEBUG and DEBUG1 are equivalent, and DEBUG2 and DEBUG3 each specify higher levels of debugging output.
Logging with a DEBUG level violates the privacy of users and is not recommended. Like, actually โ€” don't do it ๐Ÿ™ˆ
  • LogVerbose โ€” specify one or more overrides to LogLevel. An override is one or more pattern lists that match the source file, function and line number to force detailed logging for. Example override pattern:
kex.c:*:1000,*:kex_exchange_identification():*,packet.c:*

which would enable detailed logging for line 1000 of kex.c, everything in the kex_exchange_identification() function, and all code in the packet.c file. This option is intended for debugging, and no overrides are enabled by default ๐Ÿ”โœจ

  • MACs โ€” the available MAC (message authentication code) algorithms. The MAC algorithm handles data integrity protection. Multiple algorithms must be comma-separated. Same prefix rules as ever, bestie:
    • + โ†’ the specified algorithms get appended to the default set instead of replacing them ๐Ÿ’–
    • - โ†’ the specified algorithms (wildcards included) get removed from the default set instead of replacing them โœ‚๏ธ
    • ^ โ†’ the specified algorithms get placed at the head of the default set ๐Ÿ‘‘

Algorithms containing "-etm" calculate the MAC after encryption (encrypt-then-mac). These are considered safer and their use is recommended โ€” the safer girlies ๐Ÿฅฐ The supported MACs are:

hmac-md5
hmac-md5-96
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
umac-64@openssh.com
umac-128@openssh.com
hmac-md5-etm@openssh.com
hmac-md5-96-etm@openssh.com
hmac-sha1-etm@openssh.com
hmac-sha1-96-etm@openssh.com
hmac-sha2-256-etm@openssh.com
hmac-sha2-512-etm@openssh.com
umac-64-etm@openssh.com
umac-128-etm@openssh.com

The default is:

umac-64-etm@openssh.com,umac-128-etm@openssh.com,
hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
hmac-sha1-etm@openssh.com,
umac-64@openssh.com,umac-128@openssh.com,
hmac-sha2-256,hmac-sha2-512,hmac-sha1

The list of available MAC algorithms may also be obtained using "ssh -Q mac" ๐Ÿฆ‹


๐ŸŽ€ Match โ€” the conditional block ๐ŸŽ€

Match introduces a conditional block. If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file. And if a keyword appears in multiple Match blocks that are satisfied, only the first instance of the keyword is applied. First come, first served, periodt ๐Ÿ‘‘

The arguments to Match are one or more criteria-pattern pairs, or one of the single token criteria:

  • All โ€” matches all criteria
  • Invalid-User โ€” matches when the requested user-name doesn't match any known account

The available criteria are User, Group, Host, LocalAddress, LocalPort, Version, RDomain, and Address (with RDomain representing the routing domain on which the connection was received; see ip-vrf(8)).

The match patterns may consist of single entries or comma-separated lists and may use the wildcard and negation operators described in the โ€œPATTERNSโ€ section of ssh_config(5) ๐ŸŒˆ

The patterns in an Address criteria may additionally contain addresses to match in CIDR address/masklen format, such as 192.0.2.0/24 or 2001:db8::/32.

Heads up bestie: the mask length you provide must be consistent with the address โ€” it's an error to specify a mask length that's too long for the address, or one with bits set in this host portion of the address. For example, 192.0.2.0/33 and 192.0.2.0/8, respectively. Not me making that mistakeโ€ฆ okay maybe me ๐Ÿ˜ญ

The Version keyword matches against the version string of sshd(8), for example "OpenSSH_10.0" ๐Ÿ’œ

okay so bestie, on the lines following a Match keyword, only a subset of keywords may be used โ€” here's the whole VIP list: AcceptEnv, AllowAgentForwarding, AllowGroups, AllowStreamLocalForwarding, AllowTcpForwarding, AllowUsers, AuthenticationMethods, AuthorizedKeysCommand, AuthorizedKeysCommandUser, AuthorizedKeysFile, AuthorizedPrincipalsCommand, AuthorizedPrincipalsCommandUser, AuthorizedPrincipalsFile, Banner, CASignatureAlgorithms, ChannelTimeout, ChrootDirectory, ClientAliveCountMax, ClientAliveInterval, DenyGroups, DenyUsers, DisableForwarding, ExposeAuthInfo, ForceCommand, GatewayPorts, GSSAPIAuthentication, HostbasedAcceptedAlgorithms, HostbasedAuthentication, HostbasedUsesNameFromPacketOnly, IgnoreRhosts, Include, IPQoS, KbdInteractiveAuthentication, KerberosAuthentication, LogLevel, MaxAuthTries, MaxSessions, PAMServiceName, PasswordAuthentication, PermitEmptyPasswords, PermitListen, PermitOpen, PermitRootLogin, PermitTTY, PermitTunnel, PermitUserRC, PubkeyAcceptedAlgorithms, PubkeyAuthentication, PubkeyAuthOptions, RefuseConnection, RekeyLimit, RevokedKeys, SetEnv, StreamLocalBindMask, StreamLocalBindUnlink, TrustedUserCAKeys, UnusedConnectionTimeout, X11DisplayOffset, X11Forwarding and X11UseLocalhost. that's the whole guest list ๐Ÿ’…

MaxAuthTries ๐Ÿ’€

this one sets the maximum number of authentication attempts allowed per connection. once the number of failures reaches half this value, additional failures are logged. the default is 6.

MaxSessions ๐ŸŒธ

the max number of open shell, login or subsystem (e.g. sftp) sessions permitted per network connection. clients that support connection multiplexing can establish multiple sessions. setting MaxSessions to 1 will effectively disable session multiplexing, whereas setting it to 0 will prevent all shell, login and subsystem sessions while still permitting forwarding. the default is 10.

MaxStartups ๐Ÿซถ

this sets the maximum number of concurrent unauthenticated connections to the SSH daemon. additional connections will be dropped until authentication succeeds or the LoginGraceTime expires for a connection.

you can also enable random early drop by specifying three colon separated values start:rate:full (e.g. 10:30:60). the default is 10:30:100. sshd(8) will refuse connection attempts with a probability of rate/100 (30%) if there are currently start (10) unauthenticated connections. the probability increases linearly and all connection attempts are refused if the number of unauthenticated connections reaches full (60).

ModuliFile ๐Ÿ”

points at the moduli(5) file that contains the Diffie-Hellman groups used for the diffie-hellman-group-exchange-sha1 and diffie-hellman-group-exchange-sha256 key exchange methods. the default is /etc/ssh/moduli.

PAMServiceName โœจ

the service name used for Pluggable Authentication Modules (PAM) authentication, authorisation and session controls when UsePAM is enabled. the default is sshd.

PasswordAuthentication ๐Ÿ”‘

specifies whether password authentication is allowed. the default is yes.

PermitEmptyPasswords ๐Ÿ™ˆ

when password authentication is allowed, this specifies whether the server allows login to accounts with empty password strings. the default is no.

PermitListen ๐Ÿ“ก

specifies the addresses/ports on which a remote TCP port forwarding may listen. the listen specification must be one of the following forms:

PermitListen port
PermitListen host:port

multiple permissions may be specified by separating them with whitespace. an argument of any can be used to remove all restrictions and permit any listen requests. an argument of none can be used to prohibit all listen requests. the host name may contain wildcards as described in the PATTERNS section in ssh_config(5). the wildcard * can also be used in place of a port number to allow all ports. by default all port forwarding listen requests are permitted. note that the GatewayPorts option may further restrict which addresses may be listened on. note also that ssh(1) will request a listen host of localhost if no listen host was specifically requested, and this name is treated differently to explicit localhost addresses of 127.0.0.1 and ::1.

PermitOpen ๐Ÿšช

specifies the destinations to which TCP port forwarding is permitted. the forwarding specification must be one of the following forms:

PermitOpen host:port
PermitOpen IPv4_addr:port
PermitOpen [IPv6_addr]:port

multiple forwards may be specified by separating them with whitespace. an argument of any can be used to remove all restrictions and permit any forwarding requests. an argument of none can be used to prohibit all forwarding requests. the wildcard * can be used for host or port to allow all hosts or ports respectively. otherwise, no pattern matching or address lookups are performed on supplied names. by default all port forwarding requests are permitted.

PermitRootLogin ๐Ÿ‘‘

specifies whether root can log in using ssh(1). the argument must be yes, prohibit-password, forced-commands-only, or no. the default is prohibit-password.

  • if this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-interactive authentication are disabled for root.
  • if this option is set to forced-commands-only, root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). all other authentication methods are disabled for root.
  • if this option is set to no, root is not allowed to log in.

PermitTTY ๐Ÿ–ฅ๏ธ

specifies whether pty(4) allocation is permitted. the default is yes.

PermitTunnel ๐Ÿš‡

specifies whether tun(4) device forwarding is allowed. the argument must be yes, point-to-point (layer 3), ethernet (layer 2), or no. specifying yes permits both point-to-point and ethernet. the default is no.

independent of this setting, the permissions of the selected tun(4) device must allow access to the user.

PermitUserEnvironment ๐ŸŒฑ

specifies whether ~/.ssh/environment and environment= options in ~/.ssh/authorized_keys are processed by sshd(8). valid options are yes, no or a pattern-list specifying which environment variable names to accept (for example "LANG,LC_*"). the default is no.

enabling environment processing may enable users to bypass access restrictions in some configurations using mechanisms such as LD_PRELOAD. bestie, that is a real warning, not a vibe ๐Ÿ’€

PermitUserRC ๐ŸŽ€

specifies whether any ~/.ssh/rc file is executed. the default is yes.

PerSourceMaxStartups ๐Ÿงš

specifies the number of unauthenticated connections allowed from a given source address, or none if there is no limit. this limit is applied in addition to MaxStartups, whichever is lower. the default is none.

PerSourceNetBlockSize ๐Ÿฆ‹

specifies the number of bits of source address that are grouped together for the purposes of applying PerSourceMaxStartups limits. values for IPv4 and optionally IPv6 may be specified, separated by a colon. the default is 32:128, which means each address is considered individually.

PerSourcePenalties ๐Ÿšจ

controls penalties for various conditions that may represent attacks on sshd(8). if a penalty is enforced against a client then its source address and any others in the same network, as defined by PerSourceNetBlockSize, will be refused connection for a period.

a penalty doesn't affect concurrent connections in progress, but multiple penalties from the same source from concurrent connections will accumulate up to a maximum. conversely, penalties are not applied until a minimum threshold time has been accumulated.

penalties are enabled by default with the default settings listed below but may be disabled using the no keyword. the defaults may be overridden by specifying one or more of the keywords below, separated by whitespace. all keywords accept arguments, e.g. "crash:2m".

  • crash:duration โ€” specifies how long to refuse clients that cause a crash of sshd(8) (default: 90s).
  • authfail:duration โ€” specifies how long to refuse clients that disconnect after making one or more unsuccessful authentication attempts (default: 5s).
  • invaliduser:duration โ€” specifies how long to refuse clients that attempt to log in with an invalid user (default: 5s).
  • refuseconnection:duration โ€” specifies how long to refuse clients that were administratively prohibited connection via the RefuseConnection option (default: 10s).
  • noauth:duration โ€” specifies how long to refuse clients that disconnect without attempting authentication (default: 1s). this timeout should be used cautiously otherwise it may penalise legitimate scanning tools such as ssh-keyscan(1).
  • grace-exceeded:duration โ€” specifies how long to refuse clients that fail to authenticate after LoginGraceTime (default: 10s).
  • max:duration โ€” specifies the maximum time a particular source address range will be refused access for (default: 10m). repeated penalties will accumulate up to this maximum.
  • min:duration โ€” specifies the minimum penalty that must accrue before enforcement begins (default: 15s).
  • max-sources4:number, max-sources6:number โ€” okay bestie, this one sets the max number of client IPv4 and IPv6 address ranges tracked for penalties. Default? 65536 for both. No cap on the cap energy ๐Ÿ’….
  • overflow:mode โ€” controls how the server acts when max-sources4 or max-sources6 gets exceeded. Two modes, periodt:
    • deny-all โ€” denies all incoming connections other than those exempted via PerSourcePenaltyExemptList until a penalty expires.
    • permissive โ€” allows new connections by removing existing penalties early. This is the default. Note that client penalties below the min threshold count against the total number of tracked penalties. IPv4 and IPv6 addresses are tracked separately, so an overflow in one will not affect the other. Separate vibes, separate penalty pools โœจ
  • overflow6:mode โ€” lets you specify a different overflow mode for IPv6 addresses. Default is to use the same overflow mode as you specified for IPv4.
  • PerSourcePenaltyExemptList โ€” a comma-separated list of addresses to exempt from penalties. This list may contain wildcards and CIDR address/masklen ranges. Mask length must be consistent with the address โ€” it is an error to specify a mask length that is too long for the address or one with bits set in this host portion of the address. For example, 192.0.2.0/33 and 192.0.2.0/8, respectively. Default is not to exempt any addresses. ๐Ÿ™ˆ
  • PidFile โ€” the file that contains the process ID of the SSH daemon, or none to not write one. Default is /run/sshd.pid.
  • Port โ€” the port number that sshd(8) listens on. Default is 22. Multiple options of this type are permitted. See also ListenAddress.
  • PrintLastLog โ€” whether sshd(8) should print the date and time of the last user login when a user logs in interactively. Default is yes.
  • PrintMotd โ€” whether sshd(8) should print /etc/motd when a user logs in interactively. (On some systems it is also printed by the shell, /etc/profile, or equivalent.) Default is yes.
  • PubkeyAcceptedAlgorithms โ€” the signature algorithms accepted for public key authentication, as a list of comma-separated patterns. If the specified list begins with a + character, then the specified algorithms are appended to the default set instead of replacing them. If it begins with a - character, then the specified algorithms (including wildcards) are removed from the default set instead of replacing them. If it begins with a ^ character, then the specified algorithms are placed at the head of the default set. The default for this option is:
ssh-ed25519-cert-v01@openssh.com,
ecdsa-sha2-nistp256-cert-v01@openssh.com,
ecdsa-sha2-nistp384-cert-v01@openssh.com,
ecdsa-sha2-nistp521-cert-v01@openssh.com,
sk-ssh-ed25519-cert-v01@openssh.com,
sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
webauthn-sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,
rsa-sha2-512-cert-v01@openssh.com,
rsa-sha2-256-cert-v01@openssh.com,
ssh-mldsa44-ed25519-cert-v01@openssh.com,
ssh-ed25519,
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
sk-ssh-ed25519@openssh.com,
sk-ecdsa-sha2-nistp256@openssh.com,
webauthn-sk-ecdsa-sha2-nistp256@openssh.com,
rsa-sha2-512,rsa-sha2-256,
ssh-mldsa44-ed25519@openssh.com

The list of available signature algorithms may also be obtained using ssh -Q PubkeyAcceptedAlgorithms. iykyk ๐Ÿ”ฅ

  • PubkeyAuthOptions โ€” sets one or more public key authentication options. Supported keywords are:
    • none โ€” default; indicating no additional options are enabled.
    • touch-required โ€” causes public key authentication using a FIDO authenticator algorithm (i.e. ecdsa-sk or ed25519-sk) to always require the signature to attest that a physically present user explicitly confirmed the authentication (usually by touching the authenticator). By default, sshd(8) requires user presence unless overridden with an authorized_keys option. The touch-required flag disables this override.
    • verify-required โ€” requires a FIDO key signature attest that the user was verified, e.g. via a PIN.

Neither the touch-required or verify-required options have any effect for other, non-FIDO, public key types. FIDO keys stay in their own lane ๐Ÿ’…

  • PubkeyAuthentication โ€” whether public key authentication is allowed. Default is yes.
  • RefuseConnection โ€” indicates that sshd(8) should unconditionally terminate the connection. Additionally, a refuseconnection penalty may be recorded against the source of the connection if PerSourcePenalties are enabled. This option is only really useful in a Match block. Instant block energy, no cap ๐Ÿ’€
  • RekeyLimit โ€” the maximum amount of data that may be transmitted or received before the session key is renegotiated, optionally followed by a maximum amount of time that may pass before the session key is renegotiated. The first argument is specified in bytes and may have a suffix of K, M, or G to indicate Kilobytes, Megabytes, or Gigabytes, respectively. The default is between 1G and 4G, depending on the cipher. The optional second value is specified in seconds and may use any of the units documented in the โ€œTIME FORMATSโ€ section. The default value for RekeyLimit is default none, which means that rekeying is performed after the cipher's default amount of data has been sent or received and no time based rekeying is done.
  • RequiredRSASize โ€” the minimum RSA key size (in bits) that sshd(8) will accept. User and host-based authentication keys smaller than this limit will be refused. Default is 1024 bits. Note that this limit may only be raised from the default. Small keys? Not on her watch โœจ
  • RevokedKeys โ€” specifies a revoked public keys file, or none to not use one. Keys listed in this file will be refused for public key authentication. Note that if this file is not readable, then public key authentication will be refused for all users. Keys may be specified as a text file, listing one public key per line, or as an OpenSSH Key Revocation List (KRL) as generated by ssh-keygen(1). This file may be consulted for each public key authentication attempt received by sshd(8) and its contents must be consistent at all times, therefore it should only be atomically replaced and never modified in place while the server is running. For more information on KRLs, see the KEY REVOCATION LISTS section in ssh-keygen(1). Atomic replace only, bestie โ€” no live edits ๐Ÿซถ
  • SecurityKeyProvider โ€” a path to a library that will be used when loading FIDO authenticator-hosted keys, overriding the default of using the built-in USB HID support.
  • SetEnv โ€” specifies one or more environment variables to set in child sessions started by sshd(8) as NAME=VALUE. The environment value may be quoted (e.g. if it contains whitespace characters). Environment variables set by SetEnv override the default environment and any variables specified by the user via AcceptEnv or PermitUserEnvironment.
  • SshdAuthPath โ€” overrides the default path to the sshd-auth binary that is invoked to complete user authentication. Default is /usr/lib/openssh/sshd-auth. This option is intended for use by tests.
  • SshdSessionPath โ€” overrides the default path to the sshd-session binary that is invoked to handle each connection. Default is /usr/lib/openssh/sshd-session. This option is intended for use by tests.
  • StreamLocalBindMask โ€” sets the octal file creation mode mask (umask) used when creating a Unix-domain socket file for local or remote port forwarding. This option is only used for port forwarding to a Unix-domain socket file. The default value is 0177, which creates a Unix-domain socket file that is readable and writable only by the owner. Note that not all operating systems honor the file mode on Unix-domain socket files. Owner-only, iconic behavior ๐Ÿ‘‘
  • StreamLocalBindUnlink โ€” whether to remove an existing Unix-domain socket file for local or remote port forwarding before creating a new one. If the socket file already exists and StreamLocalBindUnlink is not enabled, sshd will be unable to forward the port to the Unix-domain socket file. This option is only used for port forwarding to a Unix-domain socket file. The argument must be yes or no. Default is no.
  • StrictModes โ€” whether sshd(8) should check file modes and ownership of the user's files and home directory before accepting login. This is normally desirable because novices sometimes accidentally leave their directory or files world-writable. Default is yes. Note that this does not apply to ChrootDirectory, whose permissions and ownership are checked unconditionally. ChrootDirectory does not skip the vibe check ๐Ÿ˜ญ
  • Subsystem โ€” configures an external subsystem (e.g. file transfer daemon). Arguments should be a subsystem name and a command (with optional arguments) to execute upon subsystem request. The command sftp-server implements the SFTP file transfer subsystem. file transfer main character energy ๐Ÿฆ‹
  • Subsystem (still going, bestie) โ€” so like, the name internal-sftp is the other option, and it hooks you up with an in-process SFTP server. Why do you care? Because it can genuinely simplify your life if you're using ChrootDirectory to force a different filesystem root on clients. It takes the same command line arguments as sftp-server, and even though it's in-process, settings like LogLevel or SyslogFacility do not apply to it and must be set explicitly via command line arguments. ๐Ÿ™ˆ

And yeah โ€” by default, no subsystems are defined. Go define some.

๐ŸŽ€ OPTIONS (the rest of the alphabet, we're so close) ๐ŸŽ€

  • SyslogFacility โ€” tells sshd(8) which facility code to use when it's logging stuff. The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The default is AUTH. โœจ
  • TCPKeepAlive โ€” should the system send TCP keepalive messages to the other side, yes or no? If they are sent, death of the connection or a crash of one of the machines gets properly noticed. But โ€” and here's the tradeoff โ€” it means connections will die if the route is down temporarily, and some people find that annoying. ๐Ÿ˜ค On the other hand, if TCP keepalives are not sent, sessions may hang indefinitely on the server, leaving "ghost" users and consuming server resources. ๐Ÿ’€

The default is yes (so yes, it sends TCP keepalive messages), and the server will notice if the network goes down or the client host crashes. This avoids infinitely hanging sessions. Lowkey the most useful default ever.

To disable TCP keepalive messages, set the value to no.

Fun fact: this option was formerly called KeepAlive. She rebranded. ๐Ÿ’…
  • TrustedUserCAKeys โ€” points at a file containing public keys of certificate authorities that are trusted to sign user certificates for authentication, or none to not use one. Keys are listed one per line; empty lines and comments starting with # are allowed. So if a certificate shows up for authentication and its signing CA key is listed in this file, then it may be used for authentication for any user listed in the certificate's principals list. ๐Ÿ‘‘
โš ๏ธ Careful though: certificates that lack a list of principals will not be permitted for authentication using TrustedUserCAKeys. No principals, no entry. Periodt.

For more details on certificates, see the CERTIFICATES section in ssh-keygen(1).

  • UnusedConnectionTimeout โ€” specifies whether and how quickly sshd(8) should close client connections with no open channels. And what counts as an open channel? Active shell, command execution or subsystem sessions, connected network, socket, agent or X11 forwardings. What does not count? Forwarding listeners, like the ones from the ssh(1) -R flag โ€” those aren't considered open channels and do not prevent the timeout. ๐Ÿ•ฐ๏ธ

The timeout value is specified in seconds, or you can use any of the units documented in the "TIME FORMATS" section.

๐Ÿ“Œ Note that this timeout starts when the client connection completes user authentication but before the client has an opportunity to open any channels. So be careful with short timeout values โ€” they may not give the client enough time to request and open its channels before you terminate the connection. That's giving "snatched away the snack before they could eat it." ๐Ÿ˜ญ

The default none is to never expire connections for having no open channels. This option may be useful in conjunction with ChannelTimeout. ๐Ÿซถ

  • UseDNS โ€” specifies whether sshd(8) should look up the remote host name, and check that the resolved host name for the remote IP address maps back to the very same IP address.

If this option is set to no (the default), then only addresses and not host names may be used in ~/.ssh/authorized_keys from and sshd_config Match Host directives.

  • UsePAM โ€” enables the Pluggable Authentication Module interface. If set to yes, this enables PAM authentication using KbdInteractiveAuthentication and PasswordAuthentication in addition to PAM account and session module processing for all authentication types.

Because PAM keyboard-interactive authentication usually serves an equivalent role to password authentication, you should disable either PasswordAuthentication or KbdInteractiveAuthentication.

๐Ÿšจ And big one: if UsePAM is enabled, you will not be able to run sshd(8) as a non-root user. The default is no.
  • VersionAddendum โ€” optionally specifies additional text to append to the SSH protocol banner sent by the server upon connection. The default is none. Slap your own lil signature on it if you want. ๐ŸŽ€
  • X11DisplayOffset โ€” specifies the first display number available for sshd(8)'s X11 forwarding. This prevents sshd from interfering with real X11 servers. The default is 10.
  • X11Forwarding โ€” specifies whether X11 forwarding is permitted. The argument must be yes or no. The default is no.

When X11 forwarding is enabled, there may be additional exposure to the server and to client displays if the sshd(8) proxy display is configured to listen on the wildcard address (see X11UseLocalhost), though this is not the default. Additionally, the authentication spoofing and authentication data verification and substitution occur on the client side. The security risk of using X11 forwarding is that the client's X11 display server may be exposed to attack when the SSH client requests forwarding (see the warnings for ForwardX11 in ssh_config(5)). ๐Ÿ˜ฌ A system administrator may have a stance in which they want to protect clients that may expose themselves to attack by unwittingly requesting X11 forwarding, which can warrant a no setting.

๐Ÿ’€ Note that disabling X11 forwarding does not prevent users from forwarding X11 traffic, as users can always install their own forwarders. The audacity, honestly.
  • X11UseLocalhost โ€” specifies whether sshd(8) should bind the X11 forwarding server to the loopback address or to the wildcard address. By default, sshd binds the forwarding server to the loopback address and sets the hostname part of the DISPLAY environment variable to localhost. This prevents remote hosts from connecting to the proxy display. However, some older X11 clients may not function with this configuration. X11UseLocalhost may be set to no to specify that the forwarding server should be bound to the wildcard address. The argument must be yes or no. The default is yes.
  • XAuthLocation โ€” specifies the full pathname of the xauth(1) program, or none to not use one. The default is /usr/bin/xauth.

โฐ TIME FORMATS โฐ

Okay so this is the part where you get to be cute with time. sshd(8) command-line arguments and configuration file options that specify time may be expressed using a sequence of the form: time[qualifier], where time is a positive integer value and qualifier is one of the following:

  • โŸจnoneโŸฉ โ€” seconds
  • s | S โ€” seconds
  • m | M โ€” minutes
  • h | H โ€” hours
  • d | D โ€” days
  • w | W โ€” weeks

Each member of the sequence is added together to calculate the total time value. So yes, you can stack them like a little time parfait. ๐Ÿจ

Time format examples:

600     600 seconds (10 minutes)
10m     10 minutes
1h30m   1 hour 30 minutes (90 minutes)

๐Ÿ”‘ TOKENS ๐Ÿ”‘

Arguments to some keywords can make use of tokens, which are expanded at runtime. Here's the important bit though: tokens are expanded without quoting or escaping of shell characters. It is the administrator's responsibility to ensure they are safe in the context of their use. ๐Ÿ‘€ So like, that's on you bestie.

The supported tokens in sshd_config are:

  • %% โ€” a literal %.
  • %C โ€” identifies the connection endpoints, containing four space-separated values: client address, client port number, server address, and server port number.
  • %D โ€” the routing domain in which the incoming connection was received.
  • %F โ€” the fingerprint of the CA key.
  • %f โ€” the fingerprint of the key or certificate.
  • %h โ€” the home directory of the user.
  • %i โ€” the key ID in the certificate.
  • %K โ€” the base64-encoded CA key.
  • %k โ€” the base64-encoded key or certificate for authentication.
  • %s โ€” the serial number of the certificate.
  • %T โ€” the type of the CA key.
  • %t โ€” the key or certificate type.
  • %U โ€” the numeric user ID of the target user.
  • %u โ€” the username.

Now which keyword accepts which token, because they are NOT all the same and you will get caught out:

  • AuthorizedKeysCommand accepts the tokens %%, %C, %D, %f, %h, %k, %t, %U, and %u.
  • AuthorizedKeysFile accepts the tokens %%, %h, %U, and %u.
  • AuthorizedPrincipalsCommand accepts the tokens %%, %C, %D, %F, %f, %h, %i, %K, %k, %s, %T, %t, %U, and %u.
  • AuthorizedPrincipalsFile accepts the tokens %%, %h, %U, and %u.
  • ChrootDirectory accepts the tokens %%, %h, %U, and %u.

๐Ÿ“ FILES ๐Ÿ“

  • /etc/ssh/sshd_config โ€” contains configuration data for sshd(8). This file should be writable by root only, but it is recommended (though not necessary) that it be world-readable. ๐Ÿ”’

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

sftp-server(8), sshd(8)

๐Ÿ’– AUTHORS ๐Ÿ’–

OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Niels Provos and Markus Friedl contributed support for privilege separation. Legends, all of them. ๐Ÿ‘‘


and that's the whole page, bestie!! you literally read all of SSHD_CONFIG(5) ๐ŸŽ‰ This lil beauty ships from Debian, dated August 8, 2026, and it's filed under SSHD_CONFIG(5). Go forth and configure responsibly, mwah ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from