WarnWeakCrypto
ssh(1) obtains configuration data from the following sources in the following order:
user's configuration file ( ~/.ssh/config )
system-wide configuration file ( /etc/ssh/ssh_config )
Unless noted otherwise, for each configuration directive, the first specified value will be used.
The configuration files may contain sections separated by conditional Host or Match directives. Configuration in these sections is only applied if the conditional directive that started the section matches.
Since the first obtained value for each directive is used, more host-specific declarations should be given near the beginning of the file, and general defaults at the end.
The file contains directive/values pairs, one per line. Lines starting with ‘ # ’ and empty lines are interpreted as . ‘ # ’ outside of a quoted string may be used to add a to the end of a line. Whitespace at the beginning or end of lines is ignored. Values may optionally be enclosed in double quotes (") in order to represent arguments containing spaces.
Configuration directives are separated from their values by whitespace or exactly one ‘ = ’ character (which may be surrounded by whitespace); the latter format is useful to avoid the need to quote whitespace when specifying configuration options using the ssh , scp , and sftp -o option.
The possible keywords and their meanings are as follows (note that keywords are case-insensitive and arguments are case-sensitive):
A pattern entry may be negated by prefixing it with an exclamation mark (‘!’). If a negated entry is matched, then the Host entry is ignored, regardless of whether any other patterns on the line match. Negated matches are therefore useful to provide exceptions for wildcard matches.
See PATTERNS for more information on patterns.
The canonical keyword matches only when the configuration file is being re-parsed after hostname canonicalization (see the CanonicalizeHostname option). This may be useful to specify conditions that work with canonical host names only.
The final keyword requests that the configuration be re-parsed (regardless of whether CanonicalizeHostname is enabled), and matches only during this final pass. If CanonicalizeHostname is enabled, then canonical and final match during the same pass.
The exec keyword executes the specified command under the user's shell. If the command returns a zero exit status then the condition is considered true. Commands containing whitespace characters must be quoted. Arguments to exec accept the tokens described in the TOKENS section. Commands are executed using SHELL from the user's environment. Because of this, exec should not be used in the global /etc/ssh/ssh_config to control security-sensitive configuration such as EnableSSHKeysign .
The localnetwork keyword matches the addresses of active local network interfaces against the supplied list of networks in CIDR format. This may be convenient for varying the effective configuration on devices that roam between networks. Note that network address is not a trustworthy criteria in many situations (e.g. when the network is automatically configured using DHCP) and so caution should be applied if using it to control security-sensitive configuration.
The other keywords' criteria must be single entries or comma-separated lists and may use the wildcard and negation operators described in the PATTERNS section.
The criteria for the host keyword are matched against the target hostname, after any substitution by the Hostname or CanonicalizeHostname options. The originalhost keyword matches against the hostname as it was specified on the command-line.
The tagged keyword matches a tag name specified by a prior Tag directive or on the ssh(1) command-line using the -P flag. The command keyword matches the remote command that has been requested, or the subsystem name that is being invoked (e.g. "sftp" for an SFTP session). The empty string will match the case where a command or tag has not been specified, i.e. ‘Match tag ""’. The version keyword matches against the version string of ssh(1) , for example “OpenSSH_10.0”.
The user keyword matches against the target username on the remote host. The localuser keyword matches against the name of the local user running ssh(1) (this keyword may be useful in system-wide ssh_config files).
Finally, the sessiontype keyword matches the requested session type, which may be one of shell for interactive sessions, exec for command execution sessions, subsystem for subsystem invocations such as sftp(1) , or none for transport-only sessions, such as when ssh(1) is started with the -N flag.
If this option is enabled, then the configuration files are processed again using the new target name to pick up any new configuration in matching Host and Match stanzas. A value of none disables the use of a ProxyJump host.
For example, "*.a.example.com:*.b.example.com,*.c.example.com" will allow hostnames matching "*.a.example.com" to be canonicalized to names in the "*.b.example.com" or "*.c.example.com" domains.
A single argument of "none" causes no CNAMEs to be considered for canonicalization. This is the default behaviour.
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.
ssh(1) will not accept host certificates signed using algorithms other than those specified.
Arguments to CertificateFile may use the tilde syntax to refer to a user's directory, the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.
It is possible to have multiple certificate files specified in configuration files; these certificates will be tried in sequence. Multiple CertificateFile directives will add to the list of certificates used for authentication.
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:
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.
The supported ciphers are:
The list of available ciphers may also be obtained using "ssh -Q cipher".
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 session contents. For this reason, it is not recommended to enable compression for connections that trusted and untrusted traffic.
Setting this to ask will cause ssh(1) to listen for control connections, but require confirmation using ssh-askpass(1) . If the ControlPath cannot be opened, ssh(1) will continue without connecting to a master instance.
X11 and ssh-agent(1) forwarding is supported over these multiplexed connections, however the display and agent forwarded will be the one belonging to the master connection i.e. it is not possible to forward multiple displays or agents.
Two additional options allow for opportunistic multiplexing: try to use a master connection but fall back to creating a new one if one does not already exist. These options are: auto and autoask . The latter requires confirmation like the ask option.
The argument must be [ bind_address :] port . IPv6 addresses can be specified by enclosing addresses in square brackets. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or ‘*’ indicates that the port should be available from all interfaces.
Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh(1) will act as a SOCKS server. Multiple forwardings may be specified, and additional forwardings can be given on the command line. Only the superuser can forward privileged ports.
If the ExitOnForwardFailure configuration option is set to “yes”, then a client started with the ForkAfterAuthentication configuration option being set to “yes” will wait for all remote port forwards to be successfully established before placing itself in the background. The argument to this keyword must be yes (same as the -f option) or no (the default).
Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's Unix-domain socket) can access the local agent through the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded into the agent.
X11 forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the user's X11 authorization database) can access the local X11 display through the forwarded connection. An attacker may then be able to perform activities such as keystroke monitoring if the ForwardX11Trusted option is also enabled.
If this option is set to no (the default), remote X11 clients will be considered untrusted and prevented from stealing or tampering with data belonging to trusted X11 clients. Furthermore, the xauth(1) token used for the session will be set to expire after 20 minutes. Remote clients will be refused access after this time.
See the X11 SECURITY extension specification for full details on the restrictions imposed on untrusted clients.
The -Q option of ssh(1) may be used to list supported signature algorithms. This was formerly named HostbasedKeyTypes.
If hostkeys are known for the destination host then this default is modified to prefer their algorithms.
The list of available signature algorithms may also be obtained using "ssh -Q HostKeyAlgorithms".
This option overrides the SSH_AUTH_SOCK environment variable and can be used to select a specific agent. Setting the socket name to none disables the use of an authentication agent. If the string "SSH_AUTH_SOCK" is specified, the location of the socket will be read from the SSH_AUTH_SOCK environment variable. Otherwise if the specified value begins with a ‘$’ character, then it will be treated as an environment variable containing the location of the socket.
Arguments to IdentityAgent may use the tilde syntax to refer to a user's directory, the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.
Arguments to IdentityFile may use the tilde syntax to refer to a user's directory or the tokens described in the TOKENS section. Alternately an argument of none may be used to indicate no identity files should be loaded.
It is possible to have multiple identity files specified in configuration files; all these identities will be tried in sequence. Multiple IdentityFile directives will add to the list of identities tried (this behaviour differs from that of other configuration directives).
IdentityFile may be used in conjunction with IdentitiesOnly to select which identities in an agent are offered during authentication. IdentityFile may also be used in conjunction with CertificateFile in order to provide any certificate also needed for authentication with the identity.
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. If the specified list begins with a ‘^’ character, then the specified algorithms will be placed at the head of the default set.
The list of supported key exchange algorithms may also be obtained using "ssh -Q kex".
The command is run synchronously and does not have access to the session of the ssh(1) that spawned it. It should not be used for interactive commands.
This directive is ignored unless PermitLocalCommand has been enabled.
IPv6 addresses can be specified by enclosing addresses in square brackets.
If either argument contains a '/' in it, that argument will be interpreted as a Unix-domain socket (on the corresponding host) rather than a TCP port.
Multiple forwardings may be specified, and additional forwardings can be given on the command line. Only the superuser can forward privileged ports. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or ‘*’ indicates that the port should be available from all interfaces. Unix domain socket paths may use the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.
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.
The algorithms that contain "-etm" calculate the MAC after encryption (encrypt-then-mac). These are considered safer and their use recommended.
The list of available MAC algorithms may also be obtained using "ssh -Q mac".
PermitRemoteOpen host : port
PermitRemoteOpen IPv4_addr : port
PermitRemoteOpen [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.
Arguments to ProxyCommand accept the tokens described in the TOKENS section. The command can be basically anything, and should read from its standard input and write to its standard output. It should eventually connect an sshd(8) server running on some machine, or execute sshd -i somewhere. Host key management will be done using the Hostname of the host being connected (defaulting to the name typed by the user). Setting the command to none disables this option entirely. Note that CheckHostIP is not available for connections using a proxy command.
This directive is useful in conjunction with nc(1) and its proxy support. For example, the following directive would connect via an HTTP proxy at 192.0.2.0:
Note that this option will compete with the ProxyCommand option - whichever is specified first will prevent later instances of the other from taking effect.
Note also that the configuration for the destination host (either supplied via the command-line or the configuration file) is not generally applied to jump hosts. ~/.ssh/config should be used if specific configuration is required for jump hosts.
The list of available signature algorithms may also be obtained using "ssh -Q PubkeyAcceptedAlgorithms".
IPv6 addresses can be specified by enclosing addresses in square brackets.
If either argument contains a '/' in it, that argument will be interpreted as a Unix-domain socket (on the corresponding host) rather than a TCP port.
Multiple forwardings may be specified, and additional forwardings can be given on the command line. Privileged ports can be forwarded only when logging in as root on the remote machine. Unix domain socket paths may use the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.
If the port argument is 0, the listen port will be dynamically allocated on the server and reported to the client at run time.
If the bind_address is not specified, the default is to only bind to loopback addresses. If the bind_address is ‘ * ’ or an empty string, then the forwarding is requested to listen on all interfaces. Specifying a remote bind_address will only succeed if the server's GatewayPorts option is enabled (see sshd_config(5) ).
If the specified value begins with a ‘$’ character, then it will be treated as an environment variable containing the path to the library.
See PATTERNS for more information on patterns.
It is possible to clear previously set SendEnv variable names by prefixing patterns with - . The default is not to send any environment variables.
The default value is 3. If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds.
The “VALUE” may use the tokens described in the TOKENS section and environment variables as described in the ENVIRONMENT VARIABLES section.
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.
The argument must be yes or no (the default).
If this flag is set to accept-new then ssh will automatically add new host keys to the user's known_hosts file, but will not permit connections to hosts with changed host keys. If this flag is set to no or off , ssh will automatically add new host keys to the user known hosts files and allow connections to hosts with changed hostkeys to proceed, subject to some restrictions. If this flag is set to ask (the default), new host keys will be added to the user known host files only after the user has confirmed that is what they really want to do, and ssh will refuse to connect to hosts whose host key has changed. The host keys of known hosts will be verified automatically in all cases.
The argument must be transport to enable TCP keepalive messages on the SSH transport connection to the server, yes which is an alias for transport , all to enable TCP keepalive messages on all sockets opened by ssh(1) , including sockets created for X11 or port forwarding, or no to disable TCP keepalive messages. The default is transport .
See also ServerAliveInterval for a more robust connection failure detection mechanism that works at the SSH protocol level.
The argument must be local_tun [: remote_tun ]. The devices may be specified by numerical ID or the keyword any , which uses the available tunnel device. If remote_tun is not specified, it defaults to any . The default is any:any .
Additional hostkeys are only accepted if the key used to authenticate the host was already trusted or explicitly accepted by the user, the host was authenticated via UserKnownHostsFile (i.e. not GlobalKnownHostsFile ) and the host was authenticated using a plain key and not a certificate.
UpdateHostKeys is enabled by default if the user has not overridden the default UserKnownHostsFile setting and has not enabled VerifyHostKeyDNS , otherwise UpdateHostKeys will be set to no .
If UpdateHostKeys is set to ask , then the user is asked to confirm the modifications to the known_hosts file. Confirmation is currently incompatible with ControlPersist , and will be disabled if it is enabled.
Presently, only sshd(8) from OpenSSH 6.8 and greater support the "hostkeys@openssh.com" protocol extension used to inform the client of all the server's hostkeys.
See also VERIFYING HOST KEYS in ssh(1) .
A pattern consists of zero or more non-whitespace characters, ‘*’ (a wildcard that matches zero or more characters), or ‘?’ (a wildcard that matches exactly one character). For example, to specify a set of declarations for any host in the ".co.uk" set of domains, the following pattern could be used:
The following pattern would match any host in the 192.168.0.[0-9] network range:
A pattern-list is a comma-separated list of patterns. Patterns within pattern-lists may be negated by preceding them with an exclamation mark (‘!’). For example, to allow a key to be used from anywhere within an organization except from the "dialup" pool, the following entry (in authorized_keys) could be used:
Note that a negated match will never produce a positive result by itself. For example, attempting to match "host3" against the following pattern-list will fail:
The solution here is to include a term that will yield a positive match, such as a wildcard:
Arguments to some keywords can make use of tokens, which are expanded at runtime. Tokens are expanded without quoting or escaping of shell characters. It is the user's responsibility to ensure they are safe in the context of their use.
The supported tokens in ssh_config are:
CertificateFile , ControlPath , IdentityAgent , IdentityFile , Include , KnownHostsCommand , LocalForward , Match exec , RemoteCommand , RemoteForward , RevokedHostKeys , UserKnownHostsFile and VersionAddendum accept the tokens %%, %C, %d, %h, %i, %j, %k, %L, %l, %n, %p, %r, and %u.
KnownHostsCommand additionally accepts the tokens %f, %H, %I, %K and %t.
Hostname accepts the tokens %% and %h.
LocalCommand accepts all tokens.
ProxyCommand and ProxyJump accept the tokens %%, %h, %n, %p, and %r.
Note that some of these directives build commands for execution via the shell. Because ssh(1) performs no filtering or escaping of characters that have special meaning in shell commands (e.g. quotes), it is the user's responsibility to ensure that the arguments passed to ssh(1) do not contain such characters and that tokens are appropriately quoted when used.
ENVIRONMENT VARIABLES
Arguments to some keywords can be expanded at runtime from environment variables on the client by enclosing them in ${} , for example ${ }/.ssh would refer to the user's .ssh directory. If a specified environment variable does not exist then an error will be returned and the setting for that keyword will be ignored.
The keywords CertificateFile , ControlPath , IdentityAgent , IdentityFile , Include , KnownHostsCommand , and UserKnownHostsFile support environment variables. The keywords LocalForward and RemoteForward support environment variables only for Unix domain socket paths.
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.
