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 โ€” forces sshd to use IPv4 addresses only.
  • -6 โ€” forces sshd to use IPv6 addresses only.
  • -C connection_spec โ€” specify the connection parameters to use for the -T extended test mode. if provided, any Match directives in the configuration file that would apply are applied before the configuration is written to standard output. the connection parameters are supplied as keyword=value pairs and may be supplied in any order โ€” either with multiple -C options 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. ๐Ÿ’€
  • -c host_certificate_file โ€” specifies a path to a certificate file to identify sshd during key exchange. the certificate file must match a host key file specified using the -h option or the HostKey configuration directive. they have to MATCH, bestie. it's a matching set. ๐ŸŽ€
  • -D โ€” when this option is specified, sshd will not detach and does not become a daemon. this allows easy monitoring of sshd. 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 not fork(2) and will only process one connection. this option is only intended for debugging for the server. multiple -d options increase the debugging level. Maximum is 3. don't be greedy with the -d's, three is the limit, that's the rule. ๐Ÿ”ฅ
  • -E log_file โ€” append debug logs to log_file instead of the system log.
  • -e โ€” write debug logs to standard error instead of the system log.
  • -f config_file โ€” specifies the name of the configuration file. the default is /etc/ssh/sshd_config. sshd refuses 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 to stdout and then exit. optionally, Match rules may be applied by specifying the connection parameters using one or more -C options. it's the "just read it to me" flag. ๐Ÿ“–
  • -g login_grace_time โ€” gives the grace time for clients to authenticate themselves (default 120 seconds). 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.
  • -h host_key_file โ€” specifies a file from which a host key is read. this option must be given if sshd is 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_key and /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 that sshd is being run from inetd(8).
  • -o option โ€” 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, see sshd_config(5). it's the "everything else" door. ๐Ÿšช
  • -p port โ€” specifies the port on which the server listens for connections (default 22). multiple port options are permitted. ports specified in the configuration file with the Port option are ignored when a command-line port is specified. ports specified using the ListenAddress option override command-line ports. okay so this is a whole little hierarchy, keep up: ListenAddress beats command line, command line beats Port in 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 -q she's silent but deadly competent. no receipts.
  • -T โ€” Extended test mode. check the validity of the configuration file, output the effective configuration to stdout and then exit. optionally, Match rules may be applied by specifying the connection parameters using one or more -C options. this is similar to the -G flag, but it includes the additional testing performed by the -t flag. so it's -G but 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 updating sshd reliably as configuration options may change. the vibe check for your config. โœ…
  • -u len โ€” this option is used to specify the size of the field in the utmp structure that holds the remote host name. if the resolved host name is longer than len, 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 -u0 indicates that only dotted decimal addresses should be put into the utmp file. -u0 may also be used to prevent sshd from making DNS requests unless the authentication mechanism or configuration requires it. authentication mechanisms that may require DNS include HostbasedAuthentication and using a from="pattern-list" option in a key file. configuration options that require DNS include using a USER@HOST pattern in AllowUsers or DenyUsers. phew. okay that was a lot. the short version: tiny field, long name, we use numbers instead, and -u0 means 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:

  1. 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).
  2. if the login is on a tty, records login time.
  3. 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).
  4. changes to run with normal user privileges.
  5. sets up basic environment.
  6. reads the file ~/.ssh/environment, if it exists, and users are allowed to change their environment. see the PermitUserEnvironment option in sshd_config(5).
  7. changes to user's home directory.
  8. if ~/.ssh/rc exists and the sshd_config(5) PermitUserRC option is set, runs it; else if /etc/ssh/sshrc exists, runs it; otherwise runs xauth(1). the โ€œrcโ€ files are given the X11 authentication protocol and cookie in standard input. see โ€œSSHRCโ€, below.
  9. 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 the id_ecdsa.pub, id_ecdsa_sk.pub, id_ed25519.pub, id_ed25519_sk.pub, id_mldsa44_ed25519, or the id_rsa.pub file 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 the restrict option 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 specify no-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 the PermitUserEnvironment option.
  • expiry-time="timespec" โ€” specifies a time after which the key will NOT be accepted. The time can be a YYYYMMDD[Z] date or a YYYYMMDDHHMM[SS][Z] time. Dates and times get interpreted in the system time zone unless you suffix them with a Z, 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 the PATTERNS section in ssh_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 the command option.
  • 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 the ssh(1) -R option so it may only listen on the specified host (optional) and port. IPv6 addresses can be specified by enclosing the address in square brackets. Multiple permitlisten options may be applied, separated by commas. Hostnames may include wildcards as described in the PATTERNS section in ssh_config(5). A port specification of * matches any port. Note that the setting of GatewayPorts may further restrict listen addresses. And note that ssh(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 addresses 127.0.0.1 and ::1 ๐Ÿ‘€.
  • permitopen="host:port" โ€” limits local port forwarding with the ssh(1) -L option so it may only connect to the specified host and port. IPv6 addresses can be specified by enclosing the address in square brackets. Multiple permitopen options 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 if restrict had disabled it.
  • principals="principals" โ€” on a cert-authority line, 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 the cert-authority option ๐Ÿ™ˆ.
  • pty โ€” permits tty allocation that restrict had 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 algorithms ecdsa-sk and ed25519-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 algorithms ecdsa-sk and ed25519-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 a tun(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/rc that restrict had previously disabled.
  • X11-forwarding โ€” permits X11 forwarding that restrict had 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, if PrintLastLog and PrintMotd, respectively, are enabled. It does not suppress printing of the banner specified by Banner. So it's quiet, but not that quiet.
  • ~/.rhosts โ€” This file is used for host-based authentication (see ssh(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, because sshd reads it as root. 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 with rlogin/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 form name=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 the PermitUserEnvironment option. 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 by root/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 in hosts_access(5).
  • /etc/hosts.equiv โ€” This file is for host-based authentication (see ssh(1)). It should only be writable by root. 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 in moduli(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 โ€” See motd(5).
  • /etc/nologin โ€” If this file exists, sshd refuses to let anyone except root log 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 as hosts.equiv, but allows host-based authentication without permitting login with rlogin/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 by root, readable only by root, and not accessible to others. Note that sshd does 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 by root. 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 using ssh-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 by root/the owner and should be world-readable.
  • /etc/ssh/sshd_config โ€” Contains configuration data for sshd. The file format and configuration options are described in sshd_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 by root, and should be world-readable.
  • /run/sshd โ€” chroot(2) directory used by sshd during privilege separation in the pre-authentication phase. The directory should not contain any files and must be owned by root and not group or world-writable. Empty, root-owned, locked down. Periodt. ๐Ÿ’…
  • /run/sshd.pid โ€” Contains the process ID of the sshd listening 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