3 .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4 .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 .\" All rights reserved
7 .\" As far as I am concerned, the code I have written for this software
8 .\" can be used freely for any purpose. Any derived versions of this
9 .\" software must be clearly marked as such, and if the derived work is
10 .\" incompatible with the protocol description in the RFC file, it must be
11 .\" called by a name other than "ssh" or "Secure Shell".
13 .\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved.
14 .\" Copyright (c) 1999 Aaron Campbell. All rights reserved.
15 .\" Copyright (c) 1999 Theo de Raadt. All rights reserved.
17 .\" Redistribution and use in source and binary forms, with or without
18 .\" modification, are permitted provided that the following conditions
20 .\" 1. Redistributions of source code must retain the above copyright
21 .\" notice, this list of conditions and the following disclaimer.
22 .\" 2. Redistributions in binary form must reproduce the above copyright
23 .\" notice, this list of conditions and the following disclaimer in the
24 .\" documentation and/or other materials provided with the distribution.
26 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .\" $OpenBSD: sshd.8,v 1.184 2002/06/20 19:56:07 stevesk Exp $
39 .Dd September 25, 1999
44 .Nd OpenSSH SSH daemon
49 .Op Fl f Ar config_file
50 .Op Fl g Ar login_grace_time
51 .Op Fl h Ar host_key_file
52 .Op Fl k Ar key_gen_time
58 (SSH Daemon) is the daemon program for
60 Together these programs replace rlogin and rsh, and
61 provide secure encrypted communications between two untrusted hosts
62 over an insecure network.
63 The programs are intended to be as easy to
64 install and use as possible.
67 is the daemon that listens for connections from clients.
68 It is normally started at boot from
71 daemon for each incoming connection.
72 The forked daemons handle
73 key exchange, encryption, authentication, command execution,
75 This implementation of
77 supports both SSH protocol version 1 and 2 simultaneously.
81 .Ss SSH protocol version 1
83 Each host has a host-specific RSA key
84 (normally 1024 bits) used to identify the host.
86 the daemon starts, it generates a server RSA key (normally 768 bits).
87 This key is normally regenerated every hour if it has been used, and
88 is never stored on disk.
90 Whenever a client connects the daemon responds with its public
92 The client compares the
93 RSA host key against its own database to verify that it has not changed.
94 The client then generates a 256 bit random number.
96 random number using both the host key and the server key, and sends
97 the encrypted number to the server.
98 Both sides then use this
99 random number as a session key which is used to encrypt all further
100 communications in the session.
101 The rest of the session is encrypted
102 using a conventional cipher, currently Blowfish or 3DES, with 3DES
103 being used by default.
104 The client selects the encryption algorithm
105 to use from those offered by the server.
107 Next, the server and the client enter an authentication dialog.
108 The client tries to authenticate itself using
112 authentication combined with RSA host
113 authentication, RSA challenge-response authentication, or password
114 based authentication.
116 Rhosts authentication is normally disabled
117 because it is fundamentally insecure, but can be enabled in the server
118 configuration file if desired.
119 System security is not improved unless
124 are disabled (thus completely disabling
130 .Ss SSH protocol version 2
132 Version 2 works similarly:
133 Each host has a host-specific key (RSA or DSA) used to identify the host.
134 However, when the daemon starts, it does not generate a server key.
135 Forward security is provided through a Diffie-Hellman key agreement.
136 This key agreement results in a shared session key.
138 The rest of the session is encrypted using a symmetric cipher, currently
139 128 bit AES, Blowfish, 3DES, CAST128, Arcfour, 192 bit AES, or 256 bit AES.
140 The client selects the encryption algorithm
141 to use from those offered by the server.
142 Additionally, session integrity is provided
143 through a cryptographic message authentication code
144 (hmac-sha1 or hmac-md5).
146 Protocol version 2 provides a public key based
147 user (PubkeyAuthentication) or
148 client host (HostbasedAuthentication) authentication method,
149 conventional password authentication and challenge response based methods.
151 .Ss Command execution and data forwarding
153 If the client successfully authenticates itself, a dialog for
154 preparing the session is entered.
155 At this time the client may request
156 things like allocating a pseudo-tty, forwarding X11 connections,
157 forwarding TCP/IP connections, or forwarding the authentication agent
158 connection over the secure channel.
160 Finally, the client either requests a shell or execution of a command.
161 The sides then enter session mode.
162 In this mode, either side may send
163 data at any time, and such data is forwarded to/from the shell or
164 command on the server side, and the user terminal in the client side.
166 When the user program terminates and all forwarded X11 and other
167 connections have been closed, the server sends command exit status to
168 the client, and both sides exit.
171 can be configured using command-line options or a configuration
173 Command-line options override values specified in the
177 rereads its configuration file when it receives a hangup signal,
179 by executing itself with the name it was started as, i.e.,
182 The options are as follows:
185 Specifies the number of bits in the ephemeral protocol version 1
186 server key (default 768).
189 The server sends verbose debug output to the system
190 log, and does not put itself in the background.
191 The server also will not fork and will only process one connection.
192 This option is only intended for debugging for the server.
193 Multiple -d options increase the debugging level.
196 When this option is specified,
198 will send the output to the standard error instead of the system log.
199 .It Fl f Ar configuration_file
200 Specifies the name of the configuration file.
202 .Pa /etc/ssh/sshd_config .
204 refuses to start if there is no configuration file.
205 .It Fl g Ar login_grace_time
206 Gives the grace time for clients to authenticate themselves (default
208 If the client fails to authenticate the user within
209 this many seconds, the server disconnects and exits.
210 A value of zero indicates no limit.
211 .It Fl h Ar host_key_file
212 Specifies a file from which a host key is read.
213 This option must be given if
215 is not run as root (as the normal
216 host key files are normally not readable by anyone but root).
218 .Pa /etc/ssh/ssh_host_key
219 for protocol version 1, and
220 .Pa /etc/ssh/ssh_host_rsa_key
222 .Pa /etc/ssh/ssh_host_dsa_key
223 for protocol version 2.
224 It is possible to have multiple host key files for
225 the different protocol versions and host key algorithms.
229 is being run from inetd.
232 from inetd because it needs to generate the server key before it can
233 respond to the client, and this may take tens of seconds.
234 Clients would have to wait too long if the key was regenerated every time.
235 However, with small key sizes (e.g., 512) using
239 .It Fl k Ar key_gen_time
240 Specifies how often the ephemeral protocol version 1 server key is
241 regenerated (default 3600 seconds, or one hour).
242 The motivation for regenerating the key fairly
243 often is that the key is not stored anywhere, and after about an hour,
244 it becomes impossible to recover the key for decrypting intercepted
245 communications even if the machine is cracked into or physically
247 A value of zero indicates that the key will never be regenerated.
249 Can be used to give options in the format used in the configuration file.
250 This is useful for specifying options for which there is no separate
253 Specifies the port on which the server listens for connections
255 Multiple port options are permitted.
256 Ports specified in the configuration file are ignored when a
257 command-line port is specified.
260 Nothing is sent to the system log.
261 Normally the beginning,
262 authentication, and termination of each connection is logged.
265 Only check the validity of the configuration file and sanity of the keys.
266 This is useful for updating
268 reliably as configuration options may change.
270 This option is used to specify the size of the field
273 structure that holds the remote host name.
274 If the resolved host name is longer than
276 the dotted decimal value will be used instead.
277 This allows hosts with very long host names that
278 overflow this field to still be uniquely identified.
281 indicates that only dotted decimal addresses
282 should be put into the
286 is also be used to prevent
288 from making DNS requests unless the authentication
289 mechanism or configuration requires it.
290 Authentication mechanisms that may require DNS include
291 .Cm RhostsAuthentication ,
292 .Cm RhostsRSAAuthentication ,
293 .Cm HostbasedAuthentication
295 .Cm from="pattern-list"
296 option in a key file.
297 Configuration options that require DNS include using a
303 When this option is specified
305 will not detach and does not become a daemon.
306 This allows easy monitoring of
311 to use IPv4 addresses only.
315 to use IPv6 addresses only.
317 .Sh CONFIGURATION FILE
319 reads configuration data from
320 .Pa /etc/ssh/sshd_config
321 (or the file specified with
323 on the command line).
324 The file format and configuration options are described in
327 When a user successfully logs in,
330 .Bl -enum -offset indent
332 If the login is on a tty, and no command has been specified,
333 prints last login time and
335 (unless prevented in the configuration file or by
336 .Pa $HOME/.hushlogin ;
341 If the login is on a tty, records login time.
345 .Pa /var/run/nologin ;
346 if one exists, it prints the contents and quits
349 Changes to run with normal user privileges.
351 Sets up basic environment.
354 .Pa $HOME/.ssh/environment
357 Changes to user's home directory.
361 exists, runs it; else if
368 files are given the X11
369 authentication protocol and cookie (if applicable) in standard input.
371 Runs user's shell or command.
373 .Sh AUTHORIZED_KEYS FILE FORMAT
374 .Pa $HOME/.ssh/authorized_keys
375 is the default file that lists the public keys that are
376 permitted for RSA authentication in protocol version 1
377 and for public key authentication (PubkeyAuthentication)
378 in protocol version 2.
379 .Cm AuthorizedKeysFile
380 may be used to specify an alternative file.
382 Each line of the file contains one
383 key (empty lines and lines starting with a
387 Each RSA public key consists of the following fields, separated by
388 spaces: options, bits, exponent, modulus, comment.
389 Each protocol version 2 public key consists of:
390 options, keytype, base64 encoded key, comment.
392 are optional; its presence is determined by whether the line starts
393 with a number or not (the option field never starts with a number).
394 The bits, exponent, modulus and comment fields give the RSA key for
395 protocol version 1; the
396 comment field is not used for anything (but may be convenient for the
397 user to identify the key).
398 For protocol version 2 the keytype is
403 Note that lines in this file are usually several hundred bytes long
404 (because of the size of the RSA key modulus).
405 You don't want to type them in; instead, copy the
413 enforces a minimum RSA key modulus size for protocol 1
414 and protocol 2 keys of 768 bits.
416 The options (if present) consist of comma-separated option
418 No spaces are permitted, except within double quotes.
419 The following option specifications are supported (note
420 that option keywords are case-insensitive):
422 .It Cm from="pattern-list"
423 Specifies that in addition to RSA authentication, the canonical name
424 of the remote host must be present in the comma-separated list of
430 The list may also contain
431 patterns negated by prefixing them with
433 if the canonical host name matches a negated pattern, the key is not accepted.
435 of this option is to optionally increase security: RSA authentication
436 by itself does not trust the network or name servers or anything (but
437 the key); however, if somebody somehow steals the key, the key
438 permits an intruder to log in from anywhere in the world.
439 This additional option makes using a stolen key more difficult (name
440 servers and/or routers would have to be compromised in addition to
442 .It Cm command="command"
443 Specifies that the command is executed whenever this key is used for
445 The command supplied by the user (if any) is ignored.
446 The command is run on a pty if the client requests a pty;
447 otherwise it is run without a tty.
448 If a 8-bit clean channel is required,
449 one must not request a pty or should specify
451 A quote may be included in the command by quoting it with a backslash.
452 This option might be useful
453 to restrict certain RSA keys to perform just a specific operation.
454 An example might be a key that permits remote backups but nothing else.
455 Note that the client may specify TCP/IP and/or X11
456 forwarding unless they are explicitly prohibited.
457 Note that this option applies to shell, command or subsystem execution.
458 .It Cm environment="NAME=value"
459 Specifies that the string is to be added to the environment when
460 logging in using this key.
461 Environment variables set this way
462 override other default environment values.
463 Multiple options of this type are permitted.
464 This option is automatically disabled if
467 .It Cm no-port-forwarding
468 Forbids TCP/IP forwarding when this key is used for authentication.
469 Any port forward requests by the client will return an error.
470 This might be used, e.g., in connection with the
473 .It Cm no-X11-forwarding
474 Forbids X11 forwarding when this key is used for authentication.
475 Any X11 forward requests by the client will return an error.
476 .It Cm no-agent-forwarding
477 Forbids authentication agent forwarding when this key is used for
480 Prevents tty allocation (a request to allocate a pty will fail).
481 .It Cm permitopen="host:port"
484 port forwarding such that it may only connect to the specified host and
486 IPv6 addresses can be specified with an alternative syntax:
490 options may be applied separated by commas. No pattern matching is
491 performed on the specified hostnames, they must be literal domains or
495 1024 33 12121.\|.\|.\|312314325 ylo@foo.bar
497 from="*.niksula.hut.fi,!pc.niksula.hut.fi" 1024 35 23.\|.\|.\|2334 ylo@niksula
499 command="dump /home",no-pty,no-port-forwarding 1024 33 23.\|.\|.\|2323 backup.hut.fi
501 permitopen="10.2.1.55:80",permitopen="10.2.1.56:25" 1024 33 23.\|.\|.\|2323
502 .Sh SSH_KNOWN_HOSTS FILE FORMAT
504 .Pa /etc/ssh/ssh_known_hosts
506 .Pa $HOME/.ssh/known_hosts
507 files contain host public keys for all known hosts.
508 The global file should
509 be prepared by the administrator (optional), and the per-user file is
510 maintained automatically: whenever the user connects from an unknown host
511 its key is added to the per-user file.
513 Each line in these files contains the following fields: hostnames,
514 bits, exponent, modulus, comment.
515 The fields are separated by spaces.
517 Hostnames is a comma-separated list of patterns ('*' and '?' act as
518 wildcards); each pattern in turn is matched against the canonical host
519 name (when authenticating a client) or against the user-supplied
520 name (when authenticating a server).
521 A pattern may also be preceded by
523 to indicate negation: if the host name matches a negated
524 pattern, it is not accepted (by that line) even if it matched another
527 Bits, exponent, and modulus are taken directly from the RSA host key; they
528 can be obtained, e.g., from
529 .Pa /etc/ssh/ssh_host_key.pub .
530 The optional comment field continues to the end of the line, and is not used.
534 and empty lines are ignored as comments.
536 When performing host authentication, authentication is accepted if any
537 matching line has the proper key.
538 It is thus permissible (but not
539 recommended) to have several lines or different host keys for the same
541 This will inevitably happen when short forms of host names
542 from different domains are put in the file.
544 that the files contain conflicting information; authentication is
545 accepted if valid information can be found from either file.
547 Note that the lines in these files are typically hundreds of characters
548 long, and you definitely don't want to type in the host keys by hand.
549 Rather, generate them by a script
551 .Pa /etc/ssh/ssh_host_key.pub
552 and adding the host names at the front.
555 closenet,.\|.\|.\|,130.233.208.41 1024 37 159.\|.\|.93 closenet.hut.fi
556 cvs.openbsd.org,199.185.137.3 ssh-rsa AAAA1234.....=
560 .It Pa /etc/ssh/sshd_config
561 Contains configuration data for
563 The file format and configuration options are described in
565 .It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key
566 These three files contain the private parts of the host keys.
567 These files should only be owned by root, readable only by root, and not
568 accessible to others.
571 does not start if this file is group/world-accessible.
572 .It Pa /etc/ssh/ssh_host_key.pub, /etc/ssh/ssh_host_dsa_key.pub, /etc/ssh/ssh_host_rsa_key.pub
573 These three files contain the public parts of the host keys.
574 These files should be world-readable but writable only by
576 Their contents should match the respective private parts.
578 really used for anything; they are provided for the convenience of
579 the user so their contents can be copied to known hosts files.
580 These files are created using
582 .It Pa /etc/ssh/moduli
583 Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
584 .It Pa /var/run/sshd.pid
585 Contains the process ID of the
587 listening for connections (if there are several daemons running
588 concurrently for different ports, this contains the pid of the one
590 The content of this file is not sensitive; it can be world-readable.
591 .It Pa $HOME/.ssh/authorized_keys
592 Lists the public keys (RSA or DSA) that can be used to log into the user's account.
593 This file must be readable by root (which may on some machines imply
594 it being world-readable if the user's home directory resides on an NFS
596 It is recommended that it not be accessible by others.
597 The format of this file is described above.
598 Users will place the contents of their
603 files into this file, as described in
605 .It Pa "/etc/ssh/ssh_known_hosts" and "$HOME/.ssh/known_hosts"
606 These files are consulted when using rhosts with RSA host
607 authentication or protocol version 2 hostbased authentication
608 to check the public key of the host.
609 The key must be listed in one of these files to be accepted.
610 The client uses the same files
611 to verify that it is connecting to the correct remote host.
612 These files should be writable only by root/the owner.
613 .Pa /etc/ssh/ssh_known_hosts
614 should be world-readable, and
615 .Pa $HOME/.ssh/known_hosts
616 can but need not be world-readable.
620 refuses to let anyone except root log in.
621 The contents of the file
622 are displayed to anyone trying to log in, and non-root connections are
624 The file should be world-readable.
625 .It Pa /etc/hosts.allow, /etc/hosts.deny
626 Access controls that should be enforced by tcp-wrappers are defined here.
627 Further details are described in
630 This file contains host-username pairs, separated by a space, one per
632 The given user on the corresponding host is permitted to log in
634 The same file is used by rlogind and rshd.
636 be writable only by the user; it is recommended that it not be
637 accessible by others.
639 If is also possible to use netgroups in the file.
641 name may be of the form +@groupname to specify all hosts or all users
645 this file is exactly the same as for
647 However, this file is
648 not used by rlogin and rshd, so using this permits access using SSH only.
649 .It Pa /etc/hosts.equiv
650 This file is used during
653 In the simplest form, this file contains host names, one per line.
655 those hosts are permitted to log in without a password, provided they
656 have the same user name on both machines.
657 The host name may also be
658 followed by a user name; such users are permitted to log in as
660 user on this machine (except root).
661 Additionally, the syntax
663 can be used to specify netgroups.
664 Negated entries start with
667 If the client host/user is successfully matched in this file, login is
668 automatically permitted provided the client and server user names are the
670 Additionally, successful RSA host authentication is normally required.
671 This file must be writable only by root; it is recommended
672 that it be world-readable.
674 .Sy "Warning: It is almost never a good idea to use user names in"
676 Beware that it really means that the named user(s) can log in as
678 which includes bin, daemon, adm, and other accounts that own critical
679 binaries and directories.
680 Using a user name practically grants the user root access.
681 The only valid use for user names that I can think
682 of is in negative entries.
684 Note that this warning also applies to rsh/rlogin.
685 .It Pa /etc/ssh/shosts.equiv
686 This is processed exactly as
687 .Pa /etc/hosts.equiv .
688 However, this file may be useful in environments that want to run both
690 .It Pa $HOME/.ssh/environment
691 This file is read into the environment at login (if it exists).
692 It can only contain empty lines, comment lines (that start with
694 and assignment lines of the form name=value.
695 The file should be writable
696 only by the user; it need not be readable by anyone else.
698 If this file exists, it is run with
701 environment files but before starting the user's shell or command.
702 It must not produce any output on stdout; stderr must be used
704 If X11 forwarding is in use, it will receive the "proto cookie" pair in
705 its standard input (and
712 will not run xauth automatically to add X11 cookies.
714 The primary purpose of this file is to run any initialization routines
715 which may be needed before the user's home directory becomes
716 accessible; AFS is a particular example of such an environment.
718 This file will probably contain some initialization code followed by
719 something similar to:
721 if read proto cookie && [ -n "$DISPLAY" ]; then
722 if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
723 # X11UseLocalhost=yes
724 xauth add unix:`echo $DISPLAY |
725 cut -c11-` $proto $cookie
728 xauth add $DISPLAY $proto $cookie
733 If this file does not exist,
736 does not exist either, xauth is used to add the cookie.
738 This file should be writable only by the user, and need not be
739 readable by anyone else.
740 .It Pa /etc/ssh/sshrc
743 This can be used to specify
744 machine-specific login-time initializations globally.
745 This file should be writable only by root, and should be world-readable.
748 OpenSSH is a derivative of the original and free
749 ssh 1.2.12 release by Tatu Ylonen.
750 Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
751 Theo de Raadt and Dug Song
752 removed many bugs, re-added newer features and
754 Markus Friedl contributed the support for SSH
755 protocol versions 1.5 and 2.0.
756 Niels Provos and Markus Friedl contributed support
757 for privilege separation.
775 .%T "SSH Protocol Architecture"
776 .%N draft-ietf-secsh-architecture-12.txt
778 .%O work in progress material
784 .%T "Diffie-Hellman Group Exchange for the SSH Transport Layer Protocol"
785 .%N draft-ietf-secsh-dh-group-exchange-02.txt
787 .%O work in progress material