1.\" -*- nroff -*- 2.\" 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 5.\" All rights reserved 6.\" 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". 12.\" 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. 16.\" 17.\" Redistribution and use in source and binary forms, with or without 18.\" modification, are permitted provided that the following conditions 19.\" are met: 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. 25.\" 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. 36.\" 37.\" $OpenBSD: sshd.8,v 1.170 2002/02/28 20:46:10 stevesk Exp $ 38.\" $FreeBSD$ 39.Dd March 18, 2002 40.Dt SSHD 8 41.Os 42.Sh NAME 43.Nm sshd 44.Nd OpenSSH SSH daemon 45.Sh SYNOPSIS 46.Nm sshd 47.Op Fl deiqtD46 48.Op Fl b Ar bits 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 53.Op Fl o Ar option 54.Op Fl p Ar port 55.Op Fl u Ar len 56.Sh DESCRIPTION 57.Nm 58(SSH Daemon) is the daemon program for 59.Xr ssh 1 . 60Together these programs replace rlogin and rsh, and 61provide secure encrypted communications between two untrusted hosts 62over an insecure network. 63The programs are intended to be as easy to 64install and use as possible. 65.Pp 66.Nm 67is the daemon that listens for connections from clients. 68It is normally started at boot from 69.Pa /etc/rc.network . 70It forks a new 71daemon for each incoming connection. 72The forked daemons handle 73key exchange, encryption, authentication, command execution, 74and data exchange. 75This implementation of 76.Nm 77supports both SSH protocol version 1 and 2 simultaneously. 78.Nm 79works as follows. 80.Pp 81.Ss SSH protocol version 1 82.Pp 83Each host has a host-specific RSA key 84(normally 1024 bits) used to identify the host. 85Additionally, when 86the daemon starts, it generates a server RSA key (normally 768 bits). 87This key is normally regenerated every hour if it has been used, and 88is never stored on disk. 89.Pp 90Whenever a client connects the daemon responds with its public 91host and server keys. 92The client compares the 93RSA host key against its own database to verify that it has not changed. 94The client then generates a 256 bit random number. 95It encrypts this 96random number using both the host key and the server key, and sends 97the encrypted number to the server. 98Both sides then use this 99random number as a session key which is used to encrypt all further 100communications in the session. 101The rest of the session is encrypted 102using a conventional cipher, currently Blowfish or 3DES, with 3DES 103being used by default. 104The client selects the encryption algorithm 105to use from those offered by the server. 106.Pp 107Next, the server and the client enter an authentication dialog. 108The client tries to authenticate itself using 109.Pa .rhosts 110authentication, 111.Pa .rhosts 112authentication combined with RSA host 113authentication, RSA challenge-response authentication, or password 114based authentication. 115.Pp 116Rhosts authentication is normally disabled 117because it is fundamentally insecure, but can be enabled in the server 118configuration file if desired. 119System security is not improved unless 120.Xr rshd 8 , 121.Xr rlogind 8 , 122and 123.Xr rexecd 8 124are disabled (thus completely disabling 125.Xr rlogin 1 126and 127.Xr rsh 1 128into the machine). 129.Pp 130.Ss SSH protocol version 2 131.Pp 132Version 2 works similarly: 133Each host has a host-specific key (RSA or DSA) used to identify the host. 134However, when the daemon starts, it does not generate a server key. 135Forward security is provided through a Diffie-Hellman key agreement. 136This key agreement results in a shared session key. 137.Pp 138The rest of the session is encrypted using a symmetric cipher, currently 139128 bit AES, Blowfish, 3DES, CAST128, Arcfour, 192 bit AES, or 256 bit AES. 140The client selects the encryption algorithm 141to use from those offered by the server. 142Additionally, session integrity is provided 143through a cryptographic message authentication code 144(hmac-sha1 or hmac-md5). 145.Pp 146Protocol version 2 provides a public key based 147user (PubkeyAuthentication) or 148client host (HostbasedAuthentication) authentication method, 149conventional password authentication and challenge response based methods. 150.Pp 151.Ss Command execution and data forwarding 152.Pp 153If the client successfully authenticates itself, a dialog for 154preparing the session is entered. 155At this time the client may request 156things like allocating a pseudo-tty, forwarding X11 connections, 157forwarding TCP/IP connections, or forwarding the authentication agent 158connection over the secure channel. 159.Pp 160Finally, the client either requests a shell or execution of a command. 161The sides then enter session mode. 162In this mode, either side may send 163data at any time, and such data is forwarded to/from the shell or 164command on the server side, and the user terminal in the client side. 165.Pp 166When the user program terminates and all forwarded X11 and other 167connections have been closed, the server sends command exit status to 168the client, and both sides exit. 169.Pp 170.Nm 171can be configured using command-line options or a configuration 172file. 173Command-line options override values specified in the 174configuration file. 175.Pp 176.Nm 177rereads its configuration file when it receives a hangup signal, 178.Dv SIGHUP , 179by executing itself with the name it was started as, i.e., 180.Pa /usr/sbin/sshd . 181.Pp 182The options are as follows: 183.Bl -tag -width Ds 184.It Fl b Ar bits 185Specifies the number of bits in the ephemeral protocol version 1 186server key (default 768). 187.It Fl d 188Debug mode. 189The server sends verbose debug output to the system 190log, and does not put itself in the background. 191The server also will not fork and will only process one connection. 192This option is only intended for debugging for the server. 193Multiple -d options increase the debugging level. 194Maximum is 3. 195.It Fl e 196When this option is specified, 197.Nm 198will send the output to the standard error instead of the system log. 199.It Fl f Ar configuration_file 200Specifies the name of the configuration file. 201The default is 202.Pa /etc/ssh/sshd_config . 203.Nm 204refuses to start if there is no configuration file. 205.It Fl g Ar login_grace_time 206Gives the grace time for clients to authenticate themselves (default 207600 seconds). 208If the client fails to authenticate the user within 209this many seconds, the server disconnects and exits. 210A value of zero indicates no limit. 211.It Fl h Ar host_key_file 212Specifies a file from which a host key is read. 213This option must be given if 214.Nm 215is not run as root (as the normal 216host key files are normally not readable by anyone but root). 217The default is 218.Pa /etc/ssh/ssh_host_key 219for protocol version 1, and 220.Pa /etc/ssh/ssh_host_rsa_key 221and 222.Pa /etc/ssh/ssh_host_dsa_key 223for protocol version 2. 224It is possible to have multiple host key files for 225the different protocol versions and host key algorithms. 226.It Fl i 227Specifies that 228.Nm 229is being run from inetd. 230.Nm 231is normally not run 232from inetd because it needs to generate the server key before it can 233respond to the client, and this may take tens of seconds. 234Clients would have to wait too long if the key was regenerated every time. 235However, with small key sizes (e.g., 512) using 236.Nm 237from inetd may 238be feasible. 239.It Fl k Ar key_gen_time 240Specifies how often the ephemeral protocol version 1 server key is 241regenerated (default 3600 seconds, or one hour). 242The motivation for regenerating the key fairly 243often is that the key is not stored anywhere, and after about an hour, 244it becomes impossible to recover the key for decrypting intercepted 245communications even if the machine is cracked into or physically 246seized. 247A value of zero indicates that the key will never be regenerated. 248.It Fl o Ar option 249Can be used to give options in the format used in the configuration file. 250This is useful for specifying options for which there is no separate 251command-line flag. 252.It Fl p Ar port 253Specifies the port on which the server listens for connections 254(default 22). 255Multiple port options are permitted. 256Ports specified in the configuration file are ignored when a 257command-line port is specified. 258.It Fl q 259Quiet mode. 260Nothing is sent to the system log. 261Normally the beginning, 262authentication, and termination of each connection is logged. 263.It Fl t 264Test mode. 265Only check the validity of the configuration file and sanity of the keys. 266This is useful for updating 267.Nm 268reliably as configuration options may change. 269.It Fl u Ar len 270This option is used to specify the size of the field 271in the 272.Li utmp 273structure that holds the remote host name. 274If the resolved host name is longer than 275.Ar len , 276the dotted decimal value will be used instead. 277This allows hosts with very long host names that 278overflow this field to still be uniquely identified. 279Specifying 280.Fl u0 281indicates that only dotted decimal addresses 282should be put into the 283.Pa utmp 284file. 285.Fl u0 286is also be used to prevent 287.Nm 288from making DNS requests unless the authentication 289mechanism or configuration requires it. 290Authentication mechanisms that may require DNS include 291.Cm RhostsAuthentication , 292.Cm RhostsRSAAuthentication , 293.Cm HostbasedAuthentication 294and using a 295.Cm from="pattern-list" 296option in a key file. 297Configuration options that require DNS include using a 298USER@HOST pattern in 299.Cm AllowUsers 300or 301.Cm DenyUsers . 302.It Fl D 303When this option is specified 304.Nm 305will not detach and does not become a daemon. 306This allows easy monitoring of 307.Nm sshd . 308.It Fl 4 309Forces 310.Nm 311to use IPv4 addresses only. 312.It Fl 6 313Forces 314.Nm 315to use IPv6 addresses only. 316.El 317.Sh CONFIGURATION FILE 318.Nm 319reads configuration data from 320.Pa /etc/ssh/sshd_config 321(or the file specified with 322.Fl f 323on the command line). 324The file contains keyword-argument pairs, one per line. 325Lines starting with 326.Ql # 327and empty lines are interpreted as comments. 328.Pp 329The possible 330keywords and their meanings are as follows (note that 331keywords are case-insensitive and arguments are case-sensitive): 332.Bl -tag -width Ds 333.It Cm AFSTokenPassing 334Specifies whether an AFS token may be forwarded to the server. 335Default is 336.Dq yes . 337.It Cm AllowGroups 338This keyword can be followed by a list of group name patterns, separated 339by spaces. 340If specified, login is allowed only for users whose primary 341group or supplementary group list matches one of the patterns. 342.Ql \&* 343and 344.Ql ? 345can be used as 346wildcards in the patterns. 347Only group names are valid; a numerical group ID is not recognized. 348By default, login is allowed for all groups. 349.Pp 350.It Cm AllowTcpForwarding 351Specifies whether TCP forwarding is permitted. 352The default is 353.Dq yes . 354Note that disabling TCP forwarding does not improve security unless 355users are also denied shell access, as they can always install their 356own forwarders. 357.Pp 358.It Cm AllowUsers 359This keyword can be followed by a list of user name patterns, separated 360by spaces. 361If specified, login is allowed only for users names that 362match one of the patterns. 363.Ql \&* 364and 365.Ql ? 366can be used as 367wildcards in the patterns. 368Only user names are valid; a numerical user ID is not recognized. 369By default, login is allowed for all users. 370If the pattern takes the form USER@HOST then USER and HOST 371are separately checked, restricting logins to particular 372users from particular hosts. 373.Pp 374.It Cm AuthorizedKeysFile 375Specifies the file that contains the public keys that can be used 376for user authentication. 377.Cm AuthorizedKeysFile 378may contain tokens of the form %T which are substituted during connection 379set-up. The following tokens are defined: %% is replaced by a literal '%', 380%h is replaced by the home directory of the user being authenticated and 381%u is replaced by the username of that user. 382After expansion, 383.Cm AuthorizedKeysFile 384is taken to be an absolute path or one relative to the user's home 385directory. 386The default is 387.Dq .ssh/authorized_keys . 388.It Cm Banner 389In some jurisdictions, sending a warning message before authentication 390may be relevant for getting legal protection. 391The contents of the specified file are sent to the remote user before 392authentication is allowed. 393This option is only available for protocol version 2. 394.Pp 395.It Cm ChallengeResponseAuthentication 396Specifies whether challenge response authentication is allowed. 397All authentication styles from 398.Xr login.conf 5 399are supported. 400The default is 401.Dq yes . 402Note that OPIE authentication is enabled only if 403.Cm PasswordAuthentication 404is allowed, too. 405.It Cm Ciphers 406Specifies the ciphers allowed for protocol version 2. 407Multiple ciphers must be comma-separated. 408The default is 409.Pp 410.Bd -literal 411 ``aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour, 412 aes192-cbc,aes256-cbc'' 413.Ed 414.It Cm CheckMail 415Specifies whether 416.Nm 417should notify the user of new mail for interactive logins. 418The default is 419.Dq yes . 420.It Cm ClientAliveInterval 421Sets a timeout interval in seconds after which if no data has been received 422from the client, 423.Nm 424will send a message through the encrypted 425channel to request a response from the client. 426The default 427is 0, indicating that these messages will not be sent to the client. 428This option applies to protocol version 2 only. 429.It Cm ClientAliveCountMax 430Sets the number of client alive messages (see above) which may be 431sent without 432.Nm 433receiving any messages back from the client. If this threshold is 434reached while client alive messages are being sent, 435.Nm 436will disconnect the client, terminating the session. It is important 437to note that the use of client alive messages is very different from 438.Cm KeepAlive 439(below). The client alive messages are sent through the 440encrypted channel and therefore will not be spoofable. The TCP keepalive 441option enabled by 442.Cm KeepAlive 443is spoofable. The client alive mechanism is valuable when the client or 444server depend on knowing when a connection has become inactive. 445.Pp 446The default value is 3. If 447.Cm ClientAliveInterval 448(above) is set to 15, and 449.Cm ClientAliveCountMax 450is left at the default, unresponsive ssh clients 451will be disconnected after approximately 45 seconds. 452.It Cm DenyGroups 453This keyword can be followed by a list of group name patterns, separated 454by spaces. 455Login is disallowed for users whose primary group or supplementary 456group list matches one of the patterns. 457.Ql \&* 458and 459.Ql ? 460can be used as 461wildcards in the patterns. 462Only group names are valid; a numerical group ID is not recognized. 463By default, login is allowed for all groups. 464.Pp 465.It Cm DenyUsers 466This keyword can be followed by a list of user name patterns, separated 467by spaces. 468Login is disallowed for user names that match one of the patterns. 469.Ql \&* 470and 471.Ql ? 472can be used as wildcards in the patterns. 473Only user names are valid; a numerical user ID is not recognized. 474By default, login is allowed for all users. 475If the pattern takes the form USER@HOST then USER and HOST 476are separately checked, restricting logins to particular 477users from particular hosts. 478.It Cm GatewayPorts 479Specifies whether remote hosts are allowed to connect to ports 480forwarded for the client. 481By default, 482.Nm 483binds remote port forwardings to the loopback addresss. This 484prevents other remote hosts from connecting to forwarded ports. 485.Cm GatewayPorts 486can be used to specify that 487.Nm 488should bind remote port forwardings to the wildcard address, 489thus allowing remote hosts to connect to forwarded ports. 490The argument must be 491.Dq yes 492or 493.Dq no . 494The default is 495.Dq no . 496.It Cm HostbasedAuthentication 497Specifies whether rhosts or /etc/hosts.equiv authentication together 498with successful public key client host authentication is allowed 499(hostbased authentication). 500This option is similar to 501.Cm RhostsRSAAuthentication 502and applies to protocol version 2 only. 503The default is 504.Dq no . 505.It Cm HostKey 506Specifies a file containing a private host key 507used by SSH. 508The default is 509.Pa /etc/ssh/ssh_host_key 510for protocol version 1, and 511.Pa /etc/ssh/ssh_host_rsa_key 512and 513.Pa /etc/ssh/ssh_host_dsa_key 514for protocol version 2. 515Note that 516.Nm 517will refuse to use a file if it is group/world-accessible. 518It is possible to have multiple host key files. 519.Dq rsa1 520keys are used for version 1 and 521.Dq dsa 522or 523.Dq rsa 524are used for version 2 of the SSH protocol. 525.It Cm IgnoreRhosts 526Specifies that 527.Pa .rhosts 528and 529.Pa .shosts 530files will not be used in 531.Cm RhostsAuthentication , 532.Cm RhostsRSAAuthentication 533or 534.Cm HostbasedAuthentication . 535.Pp 536.Pa /etc/hosts.equiv 537and 538.Pa /etc/ssh/shosts.equiv 539are still used. 540The default is 541.Dq yes . 542.It Cm IgnoreUserKnownHosts 543Specifies whether 544.Nm 545should ignore the user's 546.Pa $HOME/.ssh/known_hosts 547during 548.Cm RhostsRSAAuthentication 549or 550.Cm HostbasedAuthentication . 551The default is 552.Dq no . 553.It Cm KeepAlive 554Specifies whether the system should send TCP keepalive messages to the 555other side. 556If they are sent, death of the connection or crash of one 557of the machines will be properly noticed. 558However, this means that 559connections will die if the route is down temporarily, and some people 560find it annoying. 561On the other hand, if keepalives are not sent, 562sessions may hang indefinitely on the server, leaving 563.Dq ghost 564users and consuming server resources. 565.Pp 566The default is 567.Dq yes 568(to send keepalives), and the server will notice 569if the network goes down or the client host crashes. 570This avoids infinitely hanging sessions. 571.Pp 572To disable keepalives, the value should be set to 573.Dq no . 574.It Cm KerberosAuthentication 575Specifies whether Kerberos authentication is allowed. 576This can be in the form of a Kerberos ticket, or if 577.Cm PasswordAuthentication 578is yes, the password provided by the user will be validated through 579the Kerberos KDC. 580To use this option, the server needs a 581Kerberos servtab which allows the verification of the KDC's identity. 582Default is 583.Dq yes . 584.It Cm KerberosOrLocalPasswd 585If set then if password authentication through Kerberos fails then 586the password will be validated via any additional local mechanism 587such as 588.Pa /etc/passwd . 589Default is 590.Dq yes . 591.It Cm KerberosTgtPassing 592Specifies whether a Kerberos TGT may be forwarded to the server. 593Default is 594.Dq no , 595as this only works when the Kerberos KDC is actually an AFS kaserver. 596.It Cm KerberosTicketCleanup 597Specifies whether to automatically destroy the user's ticket cache 598file on logout. 599Default is 600.Dq yes . 601.It Cm KeyRegenerationInterval 602In protocol version 1, the ephemeral server key is automatically regenerated 603after this many seconds (if it has been used). 604The purpose of regeneration is to prevent 605decrypting captured sessions by later breaking into the machine and 606stealing the keys. 607The key is never stored anywhere. 608If the value is 0, the key is never regenerated. 609The default is 3600 (seconds). 610.It Cm ListenAddress 611Specifies the local addresses 612.Nm 613should listen on. 614The following forms may be used: 615.Pp 616.Bl -item -offset indent -compact 617.It 618.Cm ListenAddress 619.Sm off 620.Ar host No | Ar IPv4_addr No | Ar IPv6_addr 621.Sm on 622.It 623.Cm ListenAddress 624.Sm off 625.Ar host No | Ar IPv4_addr No : Ar port 626.Sm on 627.It 628.Cm ListenAddress 629.Sm off 630.Oo 631.Ar host No | Ar IPv6_addr Oc : Ar port 632.Sm on 633.El 634.Pp 635If 636.Ar port 637is not specified, 638.Nm 639will listen on the address and all prior 640.Cm Port 641options specified. The default is to listen on all local 642addresses. Multiple 643.Cm ListenAddress 644options are permitted. Additionally, any 645.Cm Port 646options must precede this option for non port qualified addresses. 647.It Cm LoginGraceTime 648The server disconnects after this time if the user has not 649successfully logged in. 650If the value is 0, there is no time limit. 651The default is 120 (seconds). 652.It Cm LogLevel 653Gives the verbosity level that is used when logging messages from 654.Nm sshd . 655The possible values are: 656QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2 and DEBUG3. 657The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 658and DEBUG3 each specify higher levels of debugging output. 659Logging with a DEBUG level violates the privacy of users 660and is not recommended. 661.It Cm MACs 662Specifies the available MAC (message authentication code) algorithms. 663The MAC algorithm is used in protocol version 2 664for data integrity protection. 665Multiple algorithms must be comma-separated. 666The default is 667.Dq hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 . 668.It Cm MaxStartups 669Specifies the maximum number of concurrent unauthenticated connections to the 670.Nm 671daemon. 672Additional connections will be dropped until authentication succeeds or the 673.Cm LoginGraceTime 674expires for a connection. 675The default is 10. 676.Pp 677Alternatively, random early drop can be enabled by specifying 678the three colon separated values 679.Dq start:rate:full 680(e.g., "10:30:60"). 681.Nm 682will refuse connection attempts with a probability of 683.Dq rate/100 684(30%) 685if there are currently 686.Dq start 687(10) 688unauthenticated connections. 689The probability increases linearly and all connection attempts 690are refused if the number of unauthenticated connections reaches 691.Dq full 692(60). 693.It Cm PasswordAuthentication 694Specifies whether password authentication is allowed. 695The default is 696.Dq yes . 697.It Cm PermitEmptyPasswords 698When password authentication is allowed, it specifies whether the 699server allows login to accounts with empty password strings. 700The default is 701.Dq no . 702.It Cm PermitRootLogin 703Specifies whether root can login using 704.Xr ssh 1 . 705The argument must be 706.Dq yes , 707.Dq without-password , 708.Dq forced-commands-only 709or 710.Dq no . 711The default is 712.Dq no . 713.Pp 714If this option is set to 715.Dq without-password 716password authentication is disabled for root. 717.Pp 718If this option is set to 719.Dq forced-commands-only 720root login with public key authentication will be allowed, 721but only if the 722.Ar command 723option has been specified 724(which may be useful for taking remote backups even if root login is 725normally not allowed). All other authentication methods are disabled 726for root. 727.Pp 728If this option is set to 729.Dq no 730root is not allowed to login. 731.It Cm PidFile 732Specifies the file that contains the process identifier of the 733.Nm 734daemon. 735The default is 736.Pa /var/run/sshd.pid . 737.It Cm Port 738Specifies the port number that 739.Nm 740listens on. 741The default is 22. 742Multiple options of this type are permitted. 743See also 744.Cm ListenAddress . 745.It Cm PrintLastLog 746Specifies whether 747.Nm 748should print the date and time when the user last logged in. 749The default is 750.Dq yes . 751.It Cm PrintMotd 752Specifies whether 753.Nm 754should print 755.Pa /etc/motd 756when a user logs in interactively. 757(On some systems it is also printed by the shell, 758.Pa /etc/profile , 759or equivalent.) 760The default is 761.Dq yes . 762.It Cm Protocol 763Specifies the protocol versions 764.Nm 765should support. 766The possible values are 767.Dq 1 768and 769.Dq 2 . 770Multiple versions must be comma-separated. 771The default is 772.Dq 2,1 . 773.It Cm PubkeyAuthentication 774Specifies whether public key authentication is allowed. 775The default is 776.Dq yes . 777Note that this option applies to protocol version 2 only. 778.It Cm RhostsAuthentication 779Specifies whether authentication using rhosts or 780.Pa /etc/hosts.equiv 781files is sufficient. 782Normally, this method should not be permitted because it is insecure. 783.Cm RhostsRSAAuthentication 784should be used 785instead, because it performs RSA-based host authentication in addition 786to normal rhosts or 787.Pa /etc/hosts.equiv 788authentication. 789The default is 790.Dq no . 791This option applies to protocol version 1 only. 792.It Cm RhostsRSAAuthentication 793Specifies whether rhosts or 794.Pa /etc/hosts.equiv 795authentication together 796with successful RSA host authentication is allowed. 797The default is 798.Dq no . 799This option applies to protocol version 1 only. 800.It Cm RSAAuthentication 801Specifies whether pure RSA authentication is allowed. 802The default is 803.Dq yes . 804This option applies to protocol version 1 only. 805.It Cm ServerKeyBits 806Defines the number of bits in the ephemeral protocol version 1 server key. 807The minimum value is 512, and the default is 768. 808.It Cm SkeyAuthentication 809Backward-compatibility alias for 810.Cm ChallengeResponseAuthentication . 811.It Cm StrictModes 812Specifies whether 813.Nm 814should check file modes and ownership of the 815user's files and home directory before accepting login. 816This is normally desirable because novices sometimes accidentally leave their 817directory or files world-writable. 818The default is 819.Dq yes . 820.It Cm Subsystem 821Configures an external subsystem (e.g., file transfer daemon). 822Arguments should be a subsystem name and a command to execute upon subsystem 823request. 824The command 825.Xr sftp-server 8 826implements the 827.Dq sftp 828file transfer subsystem. 829By default no subsystems are defined. 830Note that this option applies to protocol version 2 only. 831.It Cm SyslogFacility 832Gives the facility code that is used when logging messages from 833.Nm sshd . 834The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, 835LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. 836The default is AUTH. 837.It Cm UseLogin 838Specifies whether 839.Xr login 1 840is used for interactive login sessions. 841The default is 842.Dq no . 843Note that 844.Xr login 1 845is never used for remote command execution. 846Note also, that if this is enabled, 847.Cm X11Forwarding 848will be disabled because 849.Xr login 1 850does not know how to handle 851.Xr xauth 1 852cookies. 853.It Cm VerifyReverseMapping 854Specifies whether 855.Nm 856should try to verify the remote host name and check that 857the resolved host name for the remote IP address maps back to the 858very same IP address. 859The default is 860.Dq no . 861.It Cm X11DisplayOffset 862Specifies the first display number available for 863.Nm sshd Ns 's 864X11 forwarding. 865This prevents 866.Nm 867from interfering with real X11 servers. 868The default is 10. 869.It Cm X11Forwarding 870Specifies whether X11 forwarding is permitted. 871The default is 872.Dq no . 873Note that disabling X11 forwarding does not improve security in any 874way, as users can always install their own forwarders. 875X11 forwarding is automatically disabled if 876.Cm UseLogin 877is enabled. 878.It Cm X11UseLocalhost 879Specifies whether 880.Nm 881should bind the X11 forwarding server to the loopback address or to 882the wildcard address. By default, 883.Nm 884binds the forwarding server to the loopback address and sets the 885hostname part of the 886.Ev DISPLAY 887environment variable to 888.Dq localhost . 889This prevents remote hosts from connecting to the fake display. 890However, some older X11 clients may not function with this 891configuration. 892.Cm X11UseLocalhost 893may be set to 894.Dq no 895to specify that the forwarding server should be bound to the wildcard 896address. 897The argument must be 898.Dq yes 899or 900.Dq no . 901The default is 902.Dq yes . 903.It Cm XAuthLocation 904Specifies the location of the 905.Xr xauth 1 906program. 907The default is 908.Pa /usr/X11R6/bin/xauth . 909.El 910.Ss Time Formats 911.Pp 912.Nm 913command-line arguments and configuration file options that specify time 914may be expressed using a sequence of the form: 915.Sm off 916.Ar time Oo Ar qualifier Oc , 917.Sm on 918where 919.Ar time 920is a positive integer value and 921.Ar qualifier 922is one of the following: 923.Pp 924.Bl -tag -width Ds -compact -offset indent 925.It Cm <none> 926seconds 927.It Cm s | Cm S 928seconds 929.It Cm m | Cm M 930minutes 931.It Cm h | Cm H 932hours 933.It Cm d | Cm D 934days 935.It Cm w | Cm W 936weeks 937.El 938.Pp 939Each member of the sequence is added together to calculate 940the total time value. 941.Pp 942Time format examples: 943.Pp 944.Bl -tag -width Ds -compact -offset indent 945.It 600 946600 seconds (10 minutes) 947.It 10m 94810 minutes 949.It 1h30m 9501 hour 30 minutes (90 minutes) 951.El 952.Sh LOGIN PROCESS 953When a user successfully logs in, 954.Nm 955does the following: 956.Bl -enum -offset indent 957.It 958If the login is on a tty, and no command has been specified, 959prints last login time and 960.Pa /etc/motd 961(unless prevented in the configuration file or by 962.Pa $HOME/.hushlogin ; 963see the 964.Sx FILES 965section). 966.It 967If the login is on a tty, records login time. 968.It 969Checks 970.Pa /etc/nologin and 971.Pa /var/run/nologin ; 972if one exists, it prints the contents and quits 973(unless root). 974.It 975Changes to run with normal user privileges. 976.It 977Sets up basic environment. 978.It 979Reads 980.Pa $HOME/.ssh/environment 981if it exists. 982.It 983Changes to user's home directory. 984.It 985If 986.Pa $HOME/.ssh/rc 987exists, runs it; else if 988.Pa /etc/ssh/sshrc 989exists, runs 990it; otherwise runs 991.Xr xauth 1 . 992The 993.Dq rc 994files are given the X11 995authentication protocol and cookie (if applicable) in standard input. 996.It 997Runs user's shell or command. 998.El 999.Sh AUTHORIZED_KEYS FILE FORMAT 1000.Pa $HOME/.ssh/authorized_keys 1001is the default file that lists the public keys that are 1002permitted for RSA authentication in protocol version 1 1003and for public key authentication (PubkeyAuthentication) 1004in protocol version 2. 1005.Cm AuthorizedKeysFile 1006may be used to specify an alternative file. 1007.Pp 1008Each line of the file contains one 1009key (empty lines and lines starting with a 1010.Ql # 1011are ignored as 1012comments). 1013Each RSA public key consists of the following fields, separated by 1014spaces: options, bits, exponent, modulus, comment. 1015Each protocol version 2 public key consists of: 1016options, keytype, base64 encoded key, comment. 1017The options fields 1018are optional; its presence is determined by whether the line starts 1019with a number or not (the option field never starts with a number). 1020The bits, exponent, modulus and comment fields give the RSA key for 1021protocol version 1; the 1022comment field is not used for anything (but may be convenient for the 1023user to identify the key). 1024For protocol version 2 the keytype is 1025.Dq ssh-dss 1026or 1027.Dq ssh-rsa . 1028.Pp 1029Note that lines in this file are usually several hundred bytes long 1030(because of the size of the RSA key modulus). 1031You don't want to type them in; instead, copy the 1032.Pa identity.pub , 1033.Pa id_dsa.pub 1034or the 1035.Pa id_rsa.pub 1036file and edit it. 1037.Pp 1038The options (if present) consist of comma-separated option 1039specifications. 1040No spaces are permitted, except within double quotes. 1041The following option specifications are supported (note 1042that option keywords are case-insensitive): 1043.Bl -tag -width Ds 1044.It Cm from="pattern-list" 1045Specifies that in addition to RSA authentication, the canonical name 1046of the remote host must be present in the comma-separated list of 1047patterns 1048.Pf ( Ql * 1049and 1050.Ql ? 1051serve as wildcards). 1052The list may also contain 1053patterns negated by prefixing them with 1054.Ql ! ; 1055if the canonical host name matches a negated pattern, the key is not accepted. 1056The purpose 1057of this option is to optionally increase security: RSA authentication 1058by itself does not trust the network or name servers or anything (but 1059the key); however, if somebody somehow steals the key, the key 1060permits an intruder to log in from anywhere in the world. 1061This additional option makes using a stolen key more difficult (name 1062servers and/or routers would have to be compromised in addition to 1063just the key). 1064.It Cm command="command" 1065Specifies that the command is executed whenever this key is used for 1066authentication. 1067The command supplied by the user (if any) is ignored. 1068The command is run on a pty if the client requests a pty; 1069otherwise it is run without a tty. 1070If a 8-bit clean channel is required, 1071one must not request a pty or should specify 1072.Cm no-pty . 1073A quote may be included in the command by quoting it with a backslash. 1074This option might be useful 1075to restrict certain RSA keys to perform just a specific operation. 1076An example might be a key that permits remote backups but nothing else. 1077Note that the client may specify TCP/IP and/or X11 1078forwarding unless they are explicitly prohibited. 1079Note that this option applies to shell, command or subsystem execution. 1080.It Cm environment="NAME=value" 1081Specifies that the string is to be added to the environment when 1082logging in using this key. 1083Environment variables set this way 1084override other default environment values. 1085Multiple options of this type are permitted. 1086This option is automatically disabled if 1087.Cm UseLogin 1088is enabled. 1089.It Cm no-port-forwarding 1090Forbids TCP/IP forwarding when this key is used for authentication. 1091Any port forward requests by the client will return an error. 1092This might be used, e.g., in connection with the 1093.Cm command 1094option. 1095.It Cm no-X11-forwarding 1096Forbids X11 forwarding when this key is used for authentication. 1097Any X11 forward requests by the client will return an error. 1098.It Cm no-agent-forwarding 1099Forbids authentication agent forwarding when this key is used for 1100authentication. 1101.It Cm no-pty 1102Prevents tty allocation (a request to allocate a pty will fail). 1103.It Cm permitopen="host:port" 1104Limit local 1105.Li ``ssh -L'' 1106port forwarding such that it may only connect to the specified host and 1107port. 1108IPv6 addresses can be specified with an alternative syntax: 1109.Ar host/port . 1110Multiple 1111.Cm permitopen 1112options may be applied separated by commas. No pattern matching is 1113performed on the specified hostnames, they must be literal domains or 1114addresses. 1115.El 1116.Ss Examples 11171024 33 12121.\|.\|.\|312314325 ylo@foo.bar 1118.Pp 1119from="*.niksula.hut.fi,!pc.niksula.hut.fi" 1024 35 23.\|.\|.\|2334 ylo@niksula 1120.Pp 1121command="dump /home",no-pty,no-port-forwarding 1024 33 23.\|.\|.\|2323 backup.hut.fi 1122.Pp 1123permitopen="10.2.1.55:80",permitopen="10.2.1.56:25" 1024 33 23.\|.\|.\|2323 1124.Sh SSH_KNOWN_HOSTS FILE FORMAT 1125The 1126.Pa /etc/ssh/ssh_known_hosts 1127and 1128.Pa $HOME/.ssh/known_hosts 1129files contain host public keys for all known hosts. 1130The global file should 1131be prepared by the administrator (optional), and the per-user file is 1132maintained automatically: whenever the user connects from an unknown host 1133its key is added to the per-user file. 1134.Pp 1135Each line in these files contains the following fields: hostnames, 1136bits, exponent, modulus, comment. 1137The fields are separated by spaces. 1138.Pp 1139Hostnames is a comma-separated list of patterns ('*' and '?' act as 1140wildcards); each pattern in turn is matched against the canonical host 1141name (when authenticating a client) or against the user-supplied 1142name (when authenticating a server). 1143A pattern may also be preceded by 1144.Ql ! 1145to indicate negation: if the host name matches a negated 1146pattern, it is not accepted (by that line) even if it matched another 1147pattern on the line. 1148.Pp 1149Bits, exponent, and modulus are taken directly from the RSA host key; they 1150can be obtained, e.g., from 1151.Pa /etc/ssh/ssh_host_key.pub . 1152The optional comment field continues to the end of the line, and is not used. 1153.Pp 1154Lines starting with 1155.Ql # 1156and empty lines are ignored as comments. 1157.Pp 1158When performing host authentication, authentication is accepted if any 1159matching line has the proper key. 1160It is thus permissible (but not 1161recommended) to have several lines or different host keys for the same 1162names. 1163This will inevitably happen when short forms of host names 1164from different domains are put in the file. 1165It is possible 1166that the files contain conflicting information; authentication is 1167accepted if valid information can be found from either file. 1168.Pp 1169Note that the lines in these files are typically hundreds of characters 1170long, and you definitely don't want to type in the host keys by hand. 1171Rather, generate them by a script 1172or by taking 1173.Pa /etc/ssh/ssh_host_key.pub 1174and adding the host names at the front. 1175.Ss Examples 1176.Bd -literal 1177closenet,.\|.\|.\|,130.233.208.41 1024 37 159.\|.\|.93 closenet.hut.fi 1178cvs.openbsd.org,199.185.137.3 ssh-rsa AAAA1234.....= 1179.Ed 1180.Sh FILES 1181.Bl -tag -width Ds 1182.It Pa /etc/ssh/sshd_config 1183Contains configuration data for 1184.Nm sshd . 1185This file should be writable by root only, but it is recommended 1186(though not necessary) that it be world-readable. 1187.It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key 1188These three files contain the private parts of the host keys. 1189These files should only be owned by root, readable only by root, and not 1190accessible to others. 1191Note that 1192.Nm 1193does not start if this file is group/world-accessible. 1194.It Pa /etc/ssh/ssh_host_key.pub, /etc/ssh/ssh_host_dsa_key.pub, /etc/ssh/ssh_host_rsa_key.pub 1195These three files contain the public parts of the host keys. 1196These files should be world-readable but writable only by 1197root. 1198Their contents should match the respective private parts. 1199These files are not 1200really used for anything; they are provided for the convenience of 1201the user so their contents can be copied to known hosts files. 1202These files are created using 1203.Xr ssh-keygen 1 . 1204.It Pa /etc/moduli 1205Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 1206.It Pa /var/run/sshd.pid 1207Contains the process ID of the 1208.Nm 1209listening for connections (if there are several daemons running 1210concurrently for different ports, this contains the pid of the one 1211started last). 1212The content of this file is not sensitive; it can be world-readable. 1213.It Pa $HOME/.ssh/authorized_keys 1214Lists the public keys (RSA or DSA) that can be used to log into the user's account. 1215This file must be readable by root (which may on some machines imply 1216it being world-readable if the user's home directory resides on an NFS 1217volume). 1218It is recommended that it not be accessible by others. 1219The format of this file is described above. 1220Users will place the contents of their 1221.Pa identity.pub , 1222.Pa id_dsa.pub 1223and/or 1224.Pa id_rsa.pub 1225files into this file, as described in 1226.Xr ssh-keygen 1 . 1227.It Pa "/etc/ssh/ssh_known_hosts" and "$HOME/.ssh/known_hosts" 1228These files are consulted when using rhosts with RSA host 1229authentication or protocol version 2 hostbased authentication 1230to check the public key of the host. 1231The key must be listed in one of these files to be accepted. 1232The client uses the same files 1233to verify that it is connecting to the correct remote host. 1234These files should be writable only by root/the owner. 1235.Pa /etc/ssh/ssh_known_hosts 1236should be world-readable, and 1237.Pa $HOME/.ssh/known_hosts 1238can but need not be world-readable. 1239.It Pa /etc/nologin 1240If this file exists, 1241.Nm 1242refuses to let anyone except root log in. 1243The contents of the file 1244are displayed to anyone trying to log in, and non-root connections are 1245refused. 1246The file should be world-readable. 1247.It Pa /etc/hosts.allow, /etc/hosts.deny 1248Access controls that should be enforced by tcp-wrappers are defined here. 1249Further details are described in 1250.Xr hosts_access 5 . 1251.It Pa $HOME/.rhosts 1252This file contains host-username pairs, separated by a space, one per 1253line. 1254The given user on the corresponding host is permitted to log in 1255without password. 1256The same file is used by rlogind and rshd. 1257The file must 1258be writable only by the user; it is recommended that it not be 1259accessible by others. 1260.Pp 1261If is also possible to use netgroups in the file. 1262Either host or user 1263name may be of the form +@groupname to specify all hosts or all users 1264in the group. 1265.It Pa $HOME/.shosts 1266For ssh, 1267this file is exactly the same as for 1268.Pa .rhosts . 1269However, this file is 1270not used by rlogin and rshd, so using this permits access using SSH only. 1271.It Pa /etc/hosts.equiv 1272This file is used during 1273.Pa .rhosts 1274authentication. 1275In the simplest form, this file contains host names, one per line. 1276Users on 1277those hosts are permitted to log in without a password, provided they 1278have the same user name on both machines. 1279The host name may also be 1280followed by a user name; such users are permitted to log in as 1281.Em any 1282user on this machine (except root). 1283Additionally, the syntax 1284.Dq +@group 1285can be used to specify netgroups. 1286Negated entries start with 1287.Ql \&- . 1288.Pp 1289If the client host/user is successfully matched in this file, login is 1290automatically permitted provided the client and server user names are the 1291same. 1292Additionally, successful RSA host authentication is normally required. 1293This file must be writable only by root; it is recommended 1294that it be world-readable. 1295.Pp 1296.Sy "Warning: It is almost never a good idea to use user names in" 1297.Pa hosts.equiv . 1298Beware that it really means that the named user(s) can log in as 1299.Em anybody , 1300which includes bin, daemon, adm, and other accounts that own critical 1301binaries and directories. 1302Using a user name practically grants the user root access. 1303The only valid use for user names that I can think 1304of is in negative entries. 1305.Pp 1306Note that this warning also applies to rsh/rlogin. 1307.It Pa /etc/ssh/shosts.equiv 1308This is processed exactly as 1309.Pa /etc/hosts.equiv . 1310However, this file may be useful in environments that want to run both 1311rsh/rlogin and ssh. 1312.It Pa $HOME/.ssh/environment 1313This file is read into the environment at login (if it exists). 1314It can only contain empty lines, comment lines (that start with 1315.Ql # ) , 1316and assignment lines of the form name=value. 1317The file should be writable 1318only by the user; it need not be readable by anyone else. 1319.It Pa $HOME/.ssh/rc 1320If this file exists, it is run with 1321.Pa /bin/sh 1322after reading the 1323environment files but before starting the user's shell or command. 1324If X11 spoofing is in use, this will receive the "proto cookie" pair in 1325standard input (and 1326.Ev DISPLAY 1327in environment). 1328This must call 1329.Xr xauth 1 1330in that case. 1331.Pp 1332The primary purpose of this file is to run any initialization routines 1333which may be needed before the user's home directory becomes 1334accessible; AFS is a particular example of such an environment. 1335.Pp 1336This file will probably contain some initialization code followed by 1337something similar to: 1338.Bd -literal -offset indent 1339if [ -n "$DISPLAY" ] && read proto cookie; then 1340 echo add "$DISPLAY" "$proto" "$cookie" | xauth -q - 1341fi 1342.Ed 1343.Pp 1344If this file does not exist, 1345.Pa /etc/ssh/sshrc 1346is run, and if that 1347does not exist either, 1348.Xr xauth 1 1349is used to store the cookie. 1350.Pp 1351This file should be writable only by the user, and need not be 1352readable by anyone else. 1353.It Pa /etc/ssh/sshrc 1354Like 1355.Pa $HOME/.ssh/rc . 1356This can be used to specify 1357machine-specific login-time initializations globally. 1358This file should be writable only by root, and should be world-readable. 1359.El 1360.Sh AUTHORS 1361OpenSSH is a derivative of the original and free 1362ssh 1.2.12 release by Tatu Ylonen. 1363Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 1364Theo de Raadt and Dug Song 1365removed many bugs, re-added newer features and 1366created OpenSSH. 1367Markus Friedl contributed the support for SSH 1368protocol versions 1.5 and 2.0. 1369.Sh SEE ALSO 1370.Xr scp 1 , 1371.Xr sftp 1 , 1372.Xr ssh 1 , 1373.Xr ssh-add 1 , 1374.Xr ssh-agent 1 , 1375.Xr ssh-keygen 1 , 1376.Xr login.conf 5 , 1377.Xr moduli 5 , 1378.Xr sftp-server 8 1379.Rs 1380.%A T. Ylonen 1381.%A T. Kivinen 1382.%A M. Saarinen 1383.%A T. Rinne 1384.%A S. Lehtinen 1385.%T "SSH Protocol Architecture" 1386.%N draft-ietf-secsh-architecture-09.txt 1387.%D July 2001 1388.%O work in progress material 1389.Re 1390.Rs 1391.%A M. Friedl 1392.%A N. Provos 1393.%A W. A. Simpson 1394.%T "Diffie-Hellman Group Exchange for the SSH Transport Layer Protocol" 1395.%N draft-ietf-secsh-dh-group-exchange-01.txt 1396.%D April 2001 1397.%O work in progress material 1398.Re 1399