SSHD(8)
๐ SSHD(8) โ the System Manager's Manual, but make it make sense ๐
okay bestie, sit down, hydrate, because we're about to read the manual page for sshd, which is literally the OpenSSH daemon โ the main character of your entire remote-access life. this is the daemon program that runs on the server side of ssh(1), and it's giving secure encrypted communications between two untrusted hosts over an insecure network. yes, that's the whole plot. no cap.
๐ NAME ๐
sshd โ OpenSSH daemon ๐ธ
๐ฆ SYNOPSIS ๐ฆ
sshd [-46DdeGiqTtV] [-C connection_spec] [-c host_certificate_file]
[-E log_file] [-f config_file] [-g login_grace_time]
[-h host_key_file] [-o option] [-p port] [-u len]
โจ DESCRIPTION โจ
so. sshd (the OpenSSH Daemon, periodt) is the daemon program for ssh(1). it provides secure encrypted communications between two untrusted hosts over an insecure network. iconic behavior honestly.
sshd listens for connections from clients. it's normally started at boot from /etc/init.d/ssh. it forks a new daemon for each incoming connection, and those forked daemons handle key exchange, encryption, authentication, command execution, and data exchange. it's giving "one worker per problem, no sharing, we don't do teamwork here." ๐
sshd can be configured using command-line options or a configuration file (by default sshd_config(5)); command-line options override values specified in the configuration file. and when it receives a hangup signal, SIGHUP, it rereads its configuration file by executing itself with the name and options it was started with, e.g. /usr/sbin/sshd. yes she re-runs herself. self-care is real. ๐ง
the options are as follows:
-4โ forcessshdto use IPv4 addresses only.-6โ forcessshdto use IPv6 addresses only.-Cconnection_specโ specify the connection parameters to use for the-Textended test mode. if provided, anyMatchdirectives in the configuration file that would apply are applied before the configuration is written to standard output. the connection parameters are supplied askeyword=valuepairs and may be supplied in any order โ either with multiple-Coptions or as a comma-separated list. the keywords areโaddrโ,โuserโ,โhostโ,โladdrโ,โlportโ, andโrdomainโ, and they correspond to source address, user, resolved source host name, local address, local port number and routing domain respectively. additionally theโinvalid-userโflag (which does not take a value argument, okay? it's built different) may be specified to simulate a connection from an unrecognised username. ๐-chost_certificate_fileโ specifies a path to a certificate file to identifysshdduring key exchange. the certificate file must match a host key file specified using the-hoption or theHostKeyconfiguration directive. they have to MATCH, bestie. it's a matching set. ๐-Dโ when this option is specified,sshdwill not detach and does not become a daemon. this allows easy monitoring ofsshd. she stays right there in the foreground where you can see her. main character energy, no background arc.-dโ Debug mode. the server sends verbose debug output to standard error, and does not put itself in the background. the server also will notfork(2)and will only process one connection. this option is only intended for debugging for the server. multiple-doptions increase the debugging level. Maximum is 3. don't be greedy with the-d's, three is the limit, that's the rule. ๐ฅ-Elog_fileโ append debug logs tolog_fileinstead of the system log.-eโ write debug logs to standard error instead of the system log.-fconfig_fileโ specifies the name of the configuration file. the default is/etc/ssh/sshd_config.sshdrefuses to start if there is no configuration file. no config, no service, that's the deal. ๐-Gโ parse and print configuration file. check the validity of the configuration file, output the effective configuration tostdoutand then exit. optionally,Matchrules may be applied by specifying the connection parameters using one or more-Coptions. it's the "just read it to me" flag. ๐-glogin_grace_timeโ gives the grace time for clients to authenticate themselves (default120seconds). if the client fails to authenticate the user within this many seconds, the server disconnects and exits. a value of zero indicates no limit. so you can have infinite grace, but that's a choice you're making.-hhost_key_fileโ specifies a file from which a host key is read. this option must be given ifsshdis not run as root (as the normal host key files are normally not readable by anyone but root). the default is/etc/ssh/ssh_host_ecdsa_key,/etc/ssh/ssh_host_ed25519_key,/etc/ssh/ssh_host_mldsa44_ed25519_keyand/etc/ssh/ssh_host_rsa_key. it is possible to have multiple host key files for the different host key algorithms. one key per algorithm, everybody gets a turn. ๐-iโ specifies thatsshdis being run frominetd(8).-ooptionโ can be used to give options in the format used in the configuration file. this is useful for specifying options for which there is no separate command-line flag. for full details of the options, and their values, seesshd_config(5). it's the "everything else" door. ๐ช-pportโ specifies the port on which the server listens for connections (default22). multiple port options are permitted. ports specified in the configuration file with thePortoption are ignored when a command-line port is specified. ports specified using theListenAddressoption override command-line ports. okay so this is a whole little hierarchy, keep up:ListenAddressbeats command line, command line beatsPortin the config file. โญ-qโ Quiet mode. nothing is sent to the system log. normally the beginning, authentication, and termination of each connection is logged. so with-qshe's silent but deadly competent. no receipts.-Tโ Extended test mode. check the validity of the configuration file, output the effective configuration tostdoutand then exit. optionally,Matchrules may be applied by specifying the connection parameters using one or more-Coptions. this is similar to the-Gflag, but it includes the additional testing performed by the-tflag. so it's-Gbut with extra steps, and the extra steps are important. ๐-tโ Test mode. only check the validity of the configuration file and sanity of the keys. this is useful for updatingsshdreliably as configuration options may change. the vibe check for your config. โ-ulenโ this option is used to specify the size of the field in theutmpstructure that holds the remote host name. if the resolved host name is longer thanlen, the dotted decimal value will be used instead. this allows hosts with very long host names that overflow this field to still be uniquely identified. specifying-u0indicates that only dotted decimal addresses should be put into theutmpfile.-u0may also be used to preventsshdfrom making DNS requests unless the authentication mechanism or configuration requires it. authentication mechanisms that may require DNS includeHostbasedAuthenticationand using afrom="pattern-list"option in a key file. configuration options that require DNS include using aUSER@HOSTpattern inAllowUsersorDenyUsers. phew. okay that was a lot. the short version: tiny field, long name, we use numbers instead, and-u0means no DNS unless you literally force us. ๐-Vโ display the version number and exit. that's it. that's the whole job. ๐
๐ AUTHENTICATION ๐
the OpenSSH SSH daemon supports SSH protocol 2 only. each host has a host-specific key, used to identify the host. whenever a client connects, the daemon responds with its public host key. the client compares the host key against its own database to verify that it has not changed. forward secrecy is provided through a Diffie-Hellman key agreement. this key agreement results in a shared session key. the rest of the session is encrypted using a symmetric cipher. the client selects the encryption algorithm to use from those offered by the server. additionally, session integrity is provided through a cryptographic message authentication code (MAC). ๐โจ
finally, the server and the client enter an authentication dialog. the client tries to authenticate itself using host-based authentication, public key authentication, challenge-response authentication, or password authentication. pick your fighter.
regardless of the authentication type, the account is checked to ensure that it is accessible. an account is not accessible if it is locked, listed in DenyUsers, or its group is listed in DenyGroups. the definition of a locked account is system dependent. some platforms have their own account database (eg AIX) and some modify the passwd field (โ*LK*โ on Solaris and UnixWare, โ*โ on HP-UX, containing โNologinโ on Tru64, a leading โ*LOCKED*โ on FreeBSD and a leading โ!โ on most Linuxes). if there is a requirement to disable password authentication for the account while allowing still public-key, then the passwd field should be set to something other than these values (eg โNPโ or โ*NP*โ). memorize your platform's locked-account signature, bestie, they're all different and they will not tell you. ๐ญ
if the client successfully authenticates itself, a dialog for preparing the session is entered. at this time the client may request things like allocating a pseudo-tty, forwarding X11 connections, forwarding TCP connections, or forwarding the authentication agent connection over the secure channel.
after this, the client either requests an interactive shell or execution of a non-interactive command, which sshd will execute via the user's shell using its -c option. the sides then enter session mode. in this mode, either side may send data at any time, and such data is forwarded to/from the shell or command on the server side, and the user terminal in the client side.
when the user program terminates and all forwarded X11 and other connections have been closed, the server sends command exit status to the client, and both sides exit. and that's a wrap on the session. ๐ฆ
๐ธ LOGIN PROCESS ๐ธ
when a user successfully logs in, sshd does the following โ in this exact order, don't skip steps:
- if the login is on a tty, and no command has been specified, prints last login time and
/etc/motd(unless prevented in the configuration file or by~/.hushlogin; see theโFILESโsection). - if the login is on a tty, records login time.
- checks
/etc/nologin; if it exists, prints contents and quits (unless root). if that file is there, you're not getting in (unless you're root). - changes to run with normal user privileges.
- sets up basic environment.
- reads the file
~/.ssh/environment, if it exists, and users are allowed to change their environment. see thePermitUserEnvironmentoption insshd_config(5). - changes to user's home directory.
- if
~/.ssh/rcexists and thesshd_config(5)PermitUserRCoption is set, runs it; else if/etc/ssh/sshrcexists, runs it; otherwise runsxauth(1). theโrcโfiles are given the X11 authentication protocol and cookie in standard input. seeโSSHRCโ, below. - runs user's shell or command. all commands are run under the user's login shell as specified in the system password database. ๐
๐ SSHRC aka the lil "yo do this before anything else" file
okay bestie so ๐ if the file ~/.ssh/rc exists, sh(1) runs it after reading the environment files but before starting the user's shell or command. Timing matters, periodt. โฐ
โ ๏ธ IMPORTANT โ ๏ธ it must not produce any output on stdout. stderr is the only place you're allowed to yell. use it instead. no cap.
if X11 forwarding is in use, this script will receive the "proto cookie" pair in its standard input (and DISPLAY lands in its environment ๐ฅ๏ธโจ). and listen โ the script must call xauth(1) because sshd will NOT run xauth automatically to add X11 cookies. that's on you, babe. ๐
๐ธ what is this file even FOR
the primary purpose of this file is to run any initialization routines which may be needed before the user's home directory becomes accessible. AFS is a particular example of such an environment. ๐๏ธ
so basically: home dir not mounted yet, but you still need stuff to happen. that's the whole vibe. ๐ฆ
this file will probably contain some initialization code followed by something similar to:
if read proto cookie && [ -n "$DISPLAY" ]; then
if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
# X11UseLocalhost=yes
echo add unix:`echo $DISPLAY |
cut -c11-` $proto $cookie
else
# X11UseLocalhost=no
echo add $DISPLAY $proto $cookie
fi | xauth -q -
fi
look at her. she's doing so much. ๐ฅ
๐ง the fallback chain, iykyk
if this file does not exist, /etc/ssh/sshrc is run. ๐ซถ
and if that doesn't exist either? then xauth is used to add the cookie. so like, there's always a backup plan, bestie. the system will not leave you hanging. ๐
โจ AUTHORIZED_KEYS FILE FORMAT โจ
okay bestie this is THE section, the one where the magic actually lives ๐ AuthorizedKeysFile tells sshd which files hold the public keys that get to do public key auth. If you never set that option, the default is ~/.ssh/authorized_keys and ~/.ssh/authorized_keys2. Every line in the file is one key โ blank lines and lines that start with a # are just comments, ignored, no stress ๐.
A public key is a bunch of space-separated fields, in this order: options, keytype, base64-encoded key, comment. The options field? Optional, bestie, it's literally in the name ๐ .
The key types we stan are:
sk-ecdsa-sha2-nistp256@openssh.com
ecdsa-sha2-nistp256
ecdsa-sha2-nistp384
ecdsa-sha2-nistp521
sk-ssh-ed25519@openssh.com
ssh-ed25519
ssh-mldsa44-ed25519@openssh.com
ssh-rsa
The comment field does absolutely nothing functionally (it's giving decoration-only ๐ฆ) โ but it's lowkey convenient for the user to tell which key is which.
Heads up: lines in this file can be several hundred bytes long, thanks to how big the public key encoding is โ with a limit of 8 kilobytes, which allows RSA keys up to 16 kilobits. You do NOT want to type these in by hand, no cap ๐ญ. Instead, copy theid_ecdsa.pub,id_ecdsa_sk.pub,id_ed25519.pub,id_ed25519_sk.pub,id_mldsa44_ed25519, or theid_rsa.pubfile and edit that.
And sshd enforces a minimum RSA key modulus size of 1024 bits, periodt.
๐ธ The Options Field ๐ธ
The options (if you even have any) are comma-separated option specifications. No spaces allowed, except inside double quotes. Here's every option spec that's supported โ and yes, the option keywords are case-insensitive, so live your truth ๐ :
agent-forwardingโ turns authentication agent forwarding back on if therestrictoption had disabled it.cert-authorityโ this says the listed key is a certification authority (CA) that's trusted to validate signed certificates for user authentication. Certificates can encode their own access restrictions, similar to these key options. And if both certificate restrictions and key options are present? You get the most restrictive union of the two applied. Union but make it strict ๐ฅ.command="command"โ says that this command gets executed whenever this key is used for authentication. Whatever command the user supplied (if they supplied one at all) is just ignored, sorry babe ๐. The command runs on a pty if the client asks for a pty; otherwise it runs without a tty. If you need an 8-bit clean channel, you must not request a pty โ or you should specifyno-pty. You can sneak a quote into the command by quoting it with a backslash.
This one's useful for restricting certain public keys to do exactly one specific operation. Classic example: a key that permits remote backups and nothing else ๐. Note that the client can still specify TCP and/or X11 forwarding unless those are explicitly prohibited โ e.g. by using the restrict key option.
The command the client originally supplied is available in the SSH_ORIGINAL_COMMAND environment variable. This option applies to shell, command or subsystem execution. Also, this command may be superseded by a sshd_config(5) ForceCommand directive.
And one more thing: if a command is specified and a forced-command is embedded in a certificate used for authentication, then the certificate gets accepted only if the two commands are identical. Fr fr, they have to match.
environment="NAME=value"โ says this string gets added to the environment when you log in using this key. Environment variables set this way override other default environment values. You can have multiple options of this type. Environment processing is disabled by default and is controlled via thePermitUserEnvironmentoption.expiry-time="timespec"โ specifies a time after which the key will NOT be accepted. The time can be aYYYYMMDD[Z]date or aYYYYMMDDHHMM[SS][Z]time. Dates and times get interpreted in the system time zone unless you suffix them with aZ, in which case they're interpreted in the UTC time zone ๐.from="pattern-list"โ says that in addition to public key authentication, either the canonical name of the remote host or its IP address must be present in this comma-separated list of patterns. Peep thePATTERNSsection inssh_config(5)for the pattern deets.
Besides the wildcard matching you can throw at hostnames or addresses, a from stanza may match IP addresses using CIDR address/masklen notation.
Why does this option exist? To optionally increase security, bestie. Public key authentication by itself doesn't trust the network, or name servers, or anything (but the key). But if somebody somehow steals the key, that key lets an intruder log in from literally anywhere in the world ๐๐ญ. This extra option makes using a stolen key harder โ name servers and/or routers would have to be compromised in addition to just the key.
no-agent-forwardingโ forbids authentication agent forwarding when this key is used for authentication.no-port-forwardingโ forbids TCP forwarding when this key is used for authentication. Any port forward requests from the client come back as an error. Could be used, e.g., in connection with thecommandoption.no-ptyโ prevents tty allocation, so a request to allocate a pty will fail.no-user-rcโ disables execution of~/.ssh/rc.no-X11-forwardingโ forbids X11 forwarding when this key is used for authentication. Any X11 forward requests by the client come back as an error.permitlisten="[host:]port"โ limits remote port forwarding with thessh(1)-Roption so it may only listen on the specified host (optional) and port. IPv6 addresses can be specified by enclosing the address in square brackets. Multiplepermitlistenoptions may be applied, separated by commas. Hostnames may include wildcards as described in thePATTERNSsection inssh_config(5). A port specification of*matches any port. Note that the setting ofGatewayPortsmay further restrict listen addresses. And note thatssh(1)will send a hostname of "localhost" if a listen host wasn't specified when the forwarding was requested โ and that this name is treated differently to the explicit localhost addresses127.0.0.1and::1๐.permitopen="host:port"โ limits local port forwarding with thessh(1)-Loption so it may only connect to the specified host and port. IPv6 addresses can be specified by enclosing the address in square brackets. Multiplepermitopenoptions may be applied, separated by commas. No pattern matching or name lookup happens on the specified hostnames โ they must be literal host names and/or addresses. A port specification of*matches any port.port-forwardingโ turns port forwarding back on ifrestricthad disabled it.principals="principals"โ on acert-authorityline, this specifies allowed principals for certificate authentication as a comma-separated list. At least one name from the list must appear in the certificate's list of principals for the certificate to be accepted. This option is ignored for keys that aren't marked as trusted certificate signers using thecert-authorityoption ๐.ptyโ permits tty allocation thatrestricthad previously disabled.no-touch-requiredโ do not require demonstration of user presence for signatures made using this key. This option only makes sense for the FIDO authenticator algorithmsecdsa-skanded25519-sk. Chill vibes only, no tapping required ๐ซถ.verify-requiredโ require that signatures made using this key attest that they verified the user, e.g. via a PIN. This option only makes sense for the FIDO authenticator algorithmsecdsa-skanded25519-sk.restrictโ enables all the restrictions: disable port, agent and X11 forwarding, plus disable PTY allocation and execution of~/.ssh/rc. And if any future restriction capabilities get added to authorized_keys files, they'll be included in this set too. The full lock-down bundle ๐ .tunnel="n"โ forces atun(4)device on the server. Without this option, the next available device gets used if the client requests a tunnel.user-rcโ enables execution of~/.ssh/rcthatrestricthad previously disabled.X11-forwardingโ permits X11 forwarding thatrestricthad previously disabled.
๐ฆ An Example authorized_keys File ๐ฆ
Here's what it looks like irl, bestie โ copy the energy:
# Comments are allowed at start of line. Blank lines are allowed.
# Plain key, no restrictions
ssh-rsa ...
# Forced command, disable PTY and all forwarding
restrict,command="dump /home" ssh-rsa ...
# Restriction of ssh -L forwarding destinations
permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-rsa ...
# Restriction of ssh -R forwarding listeners
permitlisten="localhost:8080",permitlisten="[::1]:22000" ssh-rsa ...
# Configuration for tunnel forwarding
tunnel="0",command="sh /etc/netstart tun0" ssh-rsa ...
# Override of restriction to allow PTY allocation
restrict,pty,command="nethack" ssh-rsa ...
# Allow FIDO key without requiring touch
no-touch-required sk-ecdsa-sha2-nistp256@openssh.com ...
# Require user-verification (e.g. PIN or biometric) for FIDO key
verify-required sk-ecdsa-sha2-nistp256@openssh.com ...
# Trust CA key, allow touch-less FIDO if requested in certificate
cert-authority,no-touch-required,principals="user_a" ssh-rsa ...
โจ SSH_KNOWN_HOSTS FILE FORMAT โจ
Okay bestie, so /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts are where all the host public keys for all known hosts live. The global one is the administrator's job (optional, no pressure), and the per-user one basically runs itself: the second you connect to an unknown host, its key gets added to your per-user file. Iconic autopilot behavior, honestly. ๐
Each line in these files has these fields: marker (optional), hostnames, keytype, base64-encoded key, comment. And they're separated by spaces. Space-separated, just like your fave playlist queue. ๐
The marker is optional, but if it's there it must be one of @cert-authority (meaning "this line has a certification authority (CA) key") or @revoked (meaning "this key is revoked and must never ever be accepted, periodt"). Only one marker per key line, okay? Don't get greedy. ๐
Hostnames is a comma-separated list of patterns (* and ? act as wildcards, naturally). Each pattern gets matched against the host name. When sshd is authenticating a client โ like when using HostbasedAuthentication โ that's the canonical client host name. When ssh(1) is authenticating a server, that's the host name given by the user, or the value of the ssh(1) HostkeyAlias if it was specified, or the canonical server hostname if the ssh(1) CanonicalizeHostname option was used. Lots of options, but she's flexible. ๐
A pattern can also be preceded by ! to mean negation: if the host name matches a negated pattern, it's not accepted by that line โ even if it matched another pattern on the same line. And a hostname or address may optionally be wrapped in [ and ] brackets, then followed by : and a non-standard port number. Cute little bracket moment. ๐
Alternately, hostnames may be stored in a hashed form, which hides host names and addresses if the file's contents get disclosed. Hashed hostnames start with a | character. Only one hashed hostname can appear on a single line, and none of the above negation or wildcard operators may be applied. Rules are rules, bestie. ๐ฅ
The keytype and base64-encoded key are taken directly from the host key; you can get them, for example, from /etc/ssh/ssh_host_rsa_key.pub. The optional comment field continues to the end of the line, and it is not used. It's just there for vibes, basically. โจ
Lines starting with # and empty lines are ignored as comments.
When performing host authentication, authentication is accepted if any matching line has the proper key โ either one that matches exactly, or, if the server has presented a certificate for authentication, the key of the certification authority that signed the certificate. For a key to be trusted as a certification authority, it must use the @cert-authority marker described above. No marker, no CA trust. Simple as. ๐
The known hosts file also gives you a way to mark keys as revoked โ for example when you know the associated private key has been stolen. (Yikes. ๐ญ) Revoked keys are specified by putting the @revoked marker at the beginning of the key line, and they are never accepted for authentication or as certification authorities, but instead will produce a warning from ssh(1) when they are encountered. So they're not just silently ignored โ they get called out.
It is permissible (but not recommended) to have several lines or different host keys for the same names. This will inevitably happen when short forms of host names from different domains are put in the file. It is possible that the files contain conflicting information; authentication is accepted if valid information can be found from either file. Messy? A little. Functional? Yes. ๐
Note that the lines in these files are typically hundreds of characters long, and you definitely don't want to type in the host keys by hand. Don't do that to yourself, please. ๐
Rather, generate them by a script, ssh-keyscan(1), or by taking, for example, /etc/ssh/ssh_host_rsa_key.pub and adding the host names at the front. ssh-keygen(1) also offers some basic automated editing for ~/.ssh/known_hosts, including removing hosts matching a host name and converting all host names to their hashed representations. Slay. ๐ฆ
An example ssh_known_hosts file:
# Comments allowed at start of line
cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
# A hashed hostname
|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
AAAA1234.....=
# A revoked key
@revoked * ssh-rsa AAAAB5W...
# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
๐ FILES ๐
These are the files, bestie. Every single one. No skipping. ๐
~/.hushloginโ This file is used to suppress printing the last login time and/etc/motd, ifPrintLastLogandPrintMotd, respectively, are enabled. It does not suppress printing of the banner specified byBanner. So it's quiet, but not that quiet.~/.rhostsโ This file is used for host-based authentication (seessh(1)for more info). On some machines this file may need to be world-readable if the user's home directory is on an NFS partition, becausesshdreads it asroot. Additionally, this file must be owned by the user, and must not have write permissions for anyone else. The recommended permission for most machines is read/write for the user, and not accessible by others. Lock it down. ๐~/.shostsโ This file is used in exactly the same way as.rhosts, but allows host-based authentication without permitting login withrlogin/rsh. Same energy, better boundaries. โจ~/.ssh/โ This directory is the default location for all user-specific configuration and authentication information. There is no general requirement to keep the entire contents of this directory secret, but the recommended permissions are read/write/execute for the user, and not accessible by others. It's your little private clubhouse. ๐~/.ssh/authorized_keysโ Lists the public keys (ECDSA,Ed25519,RSA) that can be used for logging in as this user. The format of this file is described above. The content of the file is not highly sensitive, but the recommended permissions are read/write for the user, and not accessible by others.
If this file, the ~/.ssh directory, or the user's home directory are writable by other users, then the file could be modified or replaced by unauthorized users. In this case, sshd will not allow it to be used unless the StrictModes option has been set to no. And setting it to no is not the vibe, so just fix your permissions. ๐ญ
~/.ssh/environmentโ This file is read into the environment at login (if it exists). It can only contain empty lines, comment lines (that start with#), and assignment lines of the formname=value. The file should be writable only by the user; it need not be readable by anyone else. Environment processing is disabled by default and is controlled via thePermitUserEnvironmentoption. Default off, so don't be surprised. ๐~/.ssh/known_hostsโ Contains a list of host keys for all hosts the user has logged into that are not already in the systemwide list of known host keys. The format of this file is described above. This file should be writable only byroot/the owner and can, but need not be, world-readable.~/.ssh/rcโ Contains initialization routines to be run before the user's home directory becomes accessible. This file should be writable only by the user, and need not be readable by anyone else. Early bird gets the init routine. ๐ฆ/etc/hosts.allow/etc/hosts.denyโ Access controls that should be enforced by tcp-wrappers are defined here. Further details are described inhosts_access(5)./etc/hosts.equivโ This file is for host-based authentication (seessh(1)). It should only be writable byroot. Root only, no exceptions. ๐/etc/ssh/moduliโ Contains Diffie-Hellman groups used for the"Diffie-Hellman Group Exchange"key exchange method. The file format is described inmoduli(5). If no usable groups are found in this file then fixed internal groups will be used. Built-in backup groups, love that for her. โจ/etc/motdโ Seemotd(5)./etc/nologinโ If this file exists,sshdrefuses to let anyone exceptrootlog in. The contents of the file are displayed to anyone trying to log in, and non-root connections are refused. The file should be world-readable. A whole "we're closed" sign, but for logins. ๐ซ/etc/ssh/shosts.equivโ This file is used in exactly the same way ashosts.equiv, but allows host-based authentication without permitting login withrlogin/rsh. Same glow-up as.shosts./etc/ssh/ssh_host_ecdsa_key/etc/ssh/ssh_host_ed25519_key/etc/ssh/ssh_host_mldsa44_ed25519_key/etc/ssh/ssh_host_rsa_keyโ These files contain the private parts of the host keys. These files should only be owned byroot, readable only byroot, and not accessible to others. Note thatsshddoes not start if these files are group/world-accessible. So if sshd isn't starting, check these first, bestie. ๐ญ/etc/ssh/ssh_host_ecdsa_key.pub/etc/ssh/ssh_host_ed25519_key.pub/etc/ssh/ssh_host_mldsa44_ed25519_key.pub/etc/ssh/ssh_host_rsa_key.pubโ These files contain the public parts of the host keys. These files should be world-readable but writable only byroot. Their contents should match the respective private parts. These files are not really used for anything; they are provided for the convenience of the user so their contents can be copied to known hosts files. These files are created usingssh-keygen(1). Public, matching, and just chilling there for you. ๐ซถ/etc/ssh/ssh_known_hostsโ Systemwide list of known host keys. This file should be prepared by the system administrator to contain the public host keys of all machines in the organization. The format of this file is described above. This file should be writable only byroot/the owner and should be world-readable./etc/ssh/sshd_configโ Contains configuration data forsshd. The file format and configuration options are described insshd_config(5)./etc/ssh/sshrcโ Similar to~/.ssh/rc, it can be used to specify machine-specific login-time initializations globally. This file should be writable only byroot, and should be world-readable./run/sshdโchroot(2)directory used bysshdduring privilege separation in the pre-authentication phase. The directory should not contain any files and must be owned byrootand not group or world-writable. Empty, root-owned, locked down. Periodt. ๐/run/sshd.pidโ Contains the process ID of thesshdlistening for connections (if there are several daemons running concurrently for different ports, this contains the process ID of the one started last). The content of this file is not sensitive; it can be world-readable. Just a little PID moment. ๐ฅ
๐ SEE ALSO ๐
Go read these next, bestie, they're all part of the lore:
scp(1), sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1), chroot(2), hosts_access(5), moduli(5), sshd_config(5), inetd(8), sftp-server(8)
๐ AUTHORS ๐
okay bestie, storytime, because the lore here is actually iconic ๐ซถ
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. periodt, that's the origin of the whole bloodline ๐ธ
then the glow-up squad showed up: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song โ and what did they do? the way that they:
- removed many bugs ๐๐
- re-added newer features โจ
- and literally created OpenSSH ๐
not me being emotionally attached to a codebase. anyway.
Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. king behavior fr fr ๐
Niels Provos and Markus Friedl contributed support for privilege separation. that's the security girlypop move that keeps everything safe and sound ๐ ๐
and that's the whole page, bestie, we made it to the very end ๐
this cutie came from the Debian version, dated July 11, 2026, living at SSHD(8). go forth and slay โจ๐ฆ๐
๐ฆ where this page comes from
- ubuntu stonking: openssh-server 1:10.5p1-1ubuntu2
- ubuntu stonking: openssh-server 1:10.5p1-1ubuntu3.1
- ubuntu stonking: openssh-server-gssapi 1:10.5p1-1ubuntu3 ยท OpenSSH
- ubuntu stonking: openssh-server-gssapi 1:10.5p1-1ubuntu3.1 ยท OpenSSH
- Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
- Copyright (c) 1999,2000 Markus Friedl. All rights reserved
- Copyright (c) 1999 Aaron Campbell. All rights reserved
- Copyright (c) 1999 Theo de Raadt. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms