1.\" 2.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" All rights reserved 5.\" 6.\" As far as I am concerned, the code I have written for this software 7.\" can be used freely for any purpose. Any derived versions of this 8.\" software must be clearly marked as such, and if the derived work is 9.\" incompatible with the protocol description in the RFC file, it must be 10.\" called by a name other than "ssh" or "Secure Shell". 11.\" 12.\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved. 13.\" Copyright (c) 1999 Aaron Campbell. All rights reserved. 14.\" Copyright (c) 1999 Theo de Raadt. All rights reserved. 15.\" 16.\" Redistribution and use in source and binary forms, with or without 17.\" modification, are permitted provided that the following conditions 18.\" are met: 19.\" 1. Redistributions of source code must retain the above copyright 20.\" notice, this list of conditions and the following disclaimer. 21.\" 2. Redistributions in binary form must reproduce the above copyright 22.\" notice, this list of conditions and the following disclaimer in the 23.\" documentation and/or other materials provided with the distribution. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 26.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" 36.\" $OpenBSD: sshd.8,v 1.263 2011/08/02 01:22:11 djm Exp $ 37.\" $FreeBSD$ 38.Dd August 2, 2011 39.Dt SSHD 8 40.Os 41.Sh NAME 42.Nm sshd 43.Nd OpenSSH SSH daemon 44.Sh SYNOPSIS 45.Nm sshd 46.Bk -words 47.Op Fl 46DdeiqTt 48.Op Fl b Ar bits 49.Op Fl C Ar connection_spec 50.Op Fl c Ar host_certificate_file 51.Op Fl f Ar config_file 52.Op Fl g Ar login_grace_time 53.Op Fl h Ar host_key_file 54.Op Fl k Ar key_gen_time 55.Op Fl o Ar option 56.Op Fl p Ar port 57.Op Fl u Ar len 58.Ek 59.Sh DESCRIPTION 60.Nm 61(OpenSSH Daemon) is the daemon program for 62.Xr ssh 1 . 63Together these programs replace 64.Xr rlogin 1 65and 66.Xr rsh 1 , 67and provide secure encrypted communications between two untrusted hosts 68over an insecure network. 69.Pp 70.Nm 71listens for connections from clients. 72It is normally started at boot from 73.Pa /etc/rc.d/sshd . 74It forks a new 75daemon for each incoming connection. 76The forked daemons handle 77key exchange, encryption, authentication, command execution, 78and data exchange. 79.Pp 80.Nm 81can be configured using command-line options or a configuration file 82(by default 83.Xr sshd_config 5 ) ; 84command-line options override values specified in the 85configuration file. 86.Nm 87rereads its configuration file when it receives a hangup signal, 88.Dv SIGHUP , 89by executing itself with the name and options it was started with, e.g.\& 90.Pa /usr/sbin/sshd . 91.Pp 92The options are as follows: 93.Bl -tag -width Ds 94.It Fl 4 95Forces 96.Nm 97to use IPv4 addresses only. 98.It Fl 6 99Forces 100.Nm 101to use IPv6 addresses only. 102.It Fl b Ar bits 103Specifies the number of bits in the ephemeral protocol version 1 104server key (default 1024). 105.It Fl C Ar connection_spec 106Specify the connection parameters to use for the 107.Fl T 108extended test mode. 109If provided, any 110.Cm Match 111directives in the configuration file 112that would apply to the specified user, host, and address will be set before 113the configuration is written to standard output. 114The connection parameters are supplied as keyword=value pairs. 115The keywords are 116.Dq user , 117.Dq host , 118and 119.Dq addr . 120All are required and may be supplied in any order, either with multiple 121.Fl C 122options or as a comma-separated list. 123.It Fl c Ar host_certificate_file 124Specifies a path to a certificate file to identify 125.Nm 126during key exchange. 127The certificate file must match a host key file specified using the 128.Fl h 129option or the 130.Cm HostKey 131configuration directive. 132.It Fl D 133When this option is specified, 134.Nm 135will not detach and does not become a daemon. 136This allows easy monitoring of 137.Nm sshd . 138.It Fl d 139Debug mode. 140The server sends verbose debug output to standard error, 141and does not put itself in the background. 142The server also will not fork and will only process one connection. 143This option is only intended for debugging for the server. 144Multiple 145.Fl d 146options increase the debugging level. 147Maximum is 3. 148.It Fl e 149When this option is specified, 150.Nm 151will send the output to the standard error instead of the system log. 152.It Fl f Ar config_file 153Specifies the name of the configuration file. 154The default is 155.Pa /etc/ssh/sshd_config . 156.Nm 157refuses to start if there is no configuration file. 158.It Fl g Ar login_grace_time 159Gives the grace time for clients to authenticate themselves (default 160120 seconds). 161If the client fails to authenticate the user within 162this many seconds, the server disconnects and exits. 163A value of zero indicates no limit. 164.It Fl h Ar host_key_file 165Specifies a file from which a host key is read. 166This option must be given if 167.Nm 168is not run as root (as the normal 169host key files are normally not readable by anyone but root). 170The default is 171.Pa /etc/ssh/ssh_host_key 172for protocol version 1, and 173.Pa /etc/ssh/ssh_host_dsa_key , 174.Pa /etc/ssh/ssh_host_ecdsa_key 175and 176.Pa /etc/ssh/ssh_host_rsa_key 177for protocol version 2. 178It is possible to have multiple host key files for 179the different protocol versions and host key algorithms. 180.It Fl i 181Specifies that 182.Nm 183is being run from 184.Xr inetd 8 . 185.Nm 186is normally not run 187from inetd because it needs to generate the server key before it can 188respond to the client, and this may take tens of seconds. 189Clients would have to wait too long if the key was regenerated every time. 190However, with small key sizes (e.g. 512) using 191.Nm 192from inetd may 193be feasible. 194.It Fl k Ar key_gen_time 195Specifies how often the ephemeral protocol version 1 server key is 196regenerated (default 3600 seconds, or one hour). 197The motivation for regenerating the key fairly 198often is that the key is not stored anywhere, and after about an hour 199it becomes impossible to recover the key for decrypting intercepted 200communications even if the machine is cracked into or physically 201seized. 202A value of zero indicates that the key will never be regenerated. 203.It Fl o Ar option 204Can be used to give options in the format used in the configuration file. 205This is useful for specifying options for which there is no separate 206command-line flag. 207For full details of the options, and their values, see 208.Xr sshd_config 5 . 209.It Fl p Ar port 210Specifies the port on which the server listens for connections 211(default 22). 212Multiple port options are permitted. 213Ports specified in the configuration file with the 214.Cm Port 215option are ignored when a command-line port is specified. 216Ports specified using the 217.Cm ListenAddress 218option override command-line ports. 219.It Fl q 220Quiet mode. 221Nothing is sent to the system log. 222Normally the beginning, 223authentication, and termination of each connection is logged. 224.It Fl T 225Extended test mode. 226Check the validity of the configuration file, output the effective configuration 227to stdout and then exit. 228Optionally, 229.Cm Match 230rules may be applied by specifying the connection parameters using one or more 231.Fl C 232options. 233.It Fl t 234Test mode. 235Only check the validity of the configuration file and sanity of the keys. 236This is useful for updating 237.Nm 238reliably as configuration options may change. 239.It Fl u Ar len 240This option is used to specify the size of the field 241in the 242.Li utmp 243structure that holds the remote host name. 244If the resolved host name is longer than 245.Ar len , 246the dotted decimal value will be used instead. 247This allows hosts with very long host names that 248overflow this field to still be uniquely identified. 249Specifying 250.Fl u0 251indicates that only dotted decimal addresses 252should be put into the 253.Pa utmp 254file. 255.Fl u0 256may also be used to prevent 257.Nm 258from making DNS requests unless the authentication 259mechanism or configuration requires it. 260Authentication mechanisms that may require DNS include 261.Cm RhostsRSAAuthentication , 262.Cm HostbasedAuthentication , 263and using a 264.Cm from="pattern-list" 265option in a key file. 266Configuration options that require DNS include using a 267USER@HOST pattern in 268.Cm AllowUsers 269or 270.Cm DenyUsers . 271.El 272.Sh AUTHENTICATION 273The OpenSSH SSH daemon supports SSH protocols 1 and 2. 274The default is to use protocol 2 only, 275though this can be changed via the 276.Cm Protocol 277option in 278.Xr sshd_config 5 . 279Protocol 2 supports DSA, ECDSA and RSA keys; 280protocol 1 only supports RSA keys. 281For both protocols, 282each host has a host-specific key, 283normally 2048 bits, 284used to identify the host. 285.Pp 286Forward security for protocol 1 is provided through 287an additional server key, 288normally 768 bits, 289generated when the server starts. 290This key is normally regenerated every hour if it has been used, and 291is never stored on disk. 292Whenever a client connects, the daemon responds with its public 293host and server keys. 294The client compares the 295RSA host key against its own database to verify that it has not changed. 296The client then generates a 256-bit random number. 297It encrypts this 298random number using both the host key and the server key, and sends 299the encrypted number to the server. 300Both sides then use this 301random number as a session key which is used to encrypt all further 302communications in the session. 303The rest of the session is encrypted 304using a conventional cipher, currently Blowfish or 3DES, with 3DES 305being used by default. 306The client selects the encryption algorithm 307to use from those offered by the server. 308.Pp 309For protocol 2, 310forward security is provided through a Diffie-Hellman key agreement. 311This key agreement results in a shared session key. 312The rest of the session is encrypted using a symmetric cipher, currently 313128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES. 314The client selects the encryption algorithm 315to use from those offered by the server. 316Additionally, session integrity is provided 317through a cryptographic message authentication code 318(hmac-md5, hmac-sha1, umac-64, hmac-ripemd160, 319hmac-sha2-256 or hmac-sha2-512). 320.Pp 321Finally, the server and the client enter an authentication dialog. 322The client tries to authenticate itself using 323host-based authentication, 324public key authentication, 325challenge-response authentication, 326or password authentication. 327.Pp 328Regardless of the authentication type, the account is checked to 329ensure that it is accessible. An account is not accessible if it is 330locked, listed in 331.Cm DenyUsers 332or its group is listed in 333.Cm DenyGroups 334\&. The definition of a locked account is system dependant. Some platforms 335have their own account database (eg AIX) and some modify the passwd field ( 336.Ql \&*LK\&* 337on Solaris and UnixWare, 338.Ql \&* 339on HP-UX, containing 340.Ql Nologin 341on Tru64, 342a leading 343.Ql \&*LOCKED\&* 344on FreeBSD and a leading 345.Ql \&! 346on most Linuxes). 347If there is a requirement to disable password authentication 348for the account while allowing still public-key, then the passwd field 349should be set to something other than these values (eg 350.Ql NP 351or 352.Ql \&*NP\&* 353). 354.Pp 355If the client successfully authenticates itself, a dialog for 356preparing the session is entered. 357At this time the client may request 358things like allocating a pseudo-tty, forwarding X11 connections, 359forwarding TCP connections, or forwarding the authentication agent 360connection over the secure channel. 361.Pp 362After this, the client either requests a shell or execution of a command. 363The sides then enter session mode. 364In this mode, either side may send 365data at any time, and such data is forwarded to/from the shell or 366command on the server side, and the user terminal in the client side. 367.Pp 368When the user program terminates and all forwarded X11 and other 369connections have been closed, the server sends command exit status to 370the client, and both sides exit. 371.Sh LOGIN PROCESS 372When a user successfully logs in, 373.Nm 374does the following: 375.Bl -enum -offset indent 376.It 377If the login is on a tty, and no command has been specified, 378prints last login time and 379.Pa /etc/motd 380(unless prevented in the configuration file or by 381.Pa ~/.hushlogin ; 382see the 383.Sx FILES 384section). 385.It 386If the login is on a tty, records login time. 387.It 388Checks 389.Pa /etc/nologin and 390.Pa /var/run/nologin ; 391if one exists, it prints the contents and quits 392(unless root). 393.It 394Changes to run with normal user privileges. 395.It 396Sets up basic environment. 397.It 398Reads the file 399.Pa ~/.ssh/environment , 400if it exists, and users are allowed to change their environment. 401See the 402.Cm PermitUserEnvironment 403option in 404.Xr sshd_config 5 . 405.It 406Changes to user's home directory. 407.It 408If 409.Pa ~/.ssh/rc 410exists, runs it; else if 411.Pa /etc/ssh/sshrc 412exists, runs 413it; otherwise runs 414.Xr xauth 1 . 415The 416.Dq rc 417files are given the X11 418authentication protocol and cookie in standard input. 419See 420.Sx SSHRC , 421below. 422.It 423Runs user's shell or command. 424.El 425.Sh SSHRC 426If the file 427.Pa ~/.ssh/rc 428exists, 429.Xr sh 1 430runs it after reading the 431environment files but before starting the user's shell or command. 432It must not produce any output on stdout; stderr must be used 433instead. 434If X11 forwarding is in use, it will receive the "proto cookie" pair in 435its standard input (and 436.Ev DISPLAY 437in its environment). 438The script must call 439.Xr xauth 1 440because 441.Nm 442will not run xauth automatically to add X11 cookies. 443.Pp 444The primary purpose of this file is to run any initialization routines 445which may be needed before the user's home directory becomes 446accessible; AFS is a particular example of such an environment. 447.Pp 448This file will probably contain some initialization code followed by 449something similar to: 450.Bd -literal -offset 3n 451if read proto cookie && [ -n "$DISPLAY" ]; then 452 if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 453 # X11UseLocalhost=yes 454 echo add unix:`echo $DISPLAY | 455 cut -c11-` $proto $cookie 456 else 457 # X11UseLocalhost=no 458 echo add $DISPLAY $proto $cookie 459 fi | xauth -q - 460fi 461.Ed 462.Pp 463If this file does not exist, 464.Pa /etc/ssh/sshrc 465is run, and if that 466does not exist either, xauth is used to add the cookie. 467.Sh AUTHORIZED_KEYS FILE FORMAT 468.Cm AuthorizedKeysFile 469specifies the files containing public keys for 470public key authentication; 471if none is specified, the default is 472.Pa ~/.ssh/authorized_keys 473and 474.Pa ~/.ssh/authorized_keys2 . 475Each line of the file contains one 476key (empty lines and lines starting with a 477.Ql # 478are ignored as 479comments). 480Protocol 1 public keys consist of the following space-separated fields: 481options, bits, exponent, modulus, comment. 482Protocol 2 public key consist of: 483options, keytype, base64-encoded key, comment. 484The options field is optional; 485its presence is determined by whether the line starts 486with a number or not (the options field never starts with a number). 487The bits, exponent, modulus, and comment fields give the RSA key for 488protocol version 1; the 489comment field is not used for anything (but may be convenient for the 490user to identify the key). 491For protocol version 2 the keytype is 492.Dq ecdsa-sha2-nistp256 , 493.Dq ecdsa-sha2-nistp384 , 494.Dq ecdsa-sha2-nistp521 , 495.Dq ssh-dss 496or 497.Dq ssh-rsa . 498.Pp 499Note that lines in this file are usually several hundred bytes long 500(because of the size of the public key encoding) up to a limit of 5018 kilobytes, which permits DSA keys up to 8 kilobits and RSA 502keys up to 16 kilobits. 503You don't want to type them in; instead, copy the 504.Pa identity.pub , 505.Pa id_dsa.pub , 506.Pa id_ecdsa.pub , 507or the 508.Pa id_rsa.pub 509file and edit it. 510.Pp 511.Nm 512enforces a minimum RSA key modulus size for protocol 1 513and protocol 2 keys of 768 bits. 514.Pp 515The options (if present) consist of comma-separated option 516specifications. 517No spaces are permitted, except within double quotes. 518The following option specifications are supported (note 519that option keywords are case-insensitive): 520.Bl -tag -width Ds 521.It Cm cert-authority 522Specifies that the listed key is a certification authority (CA) that is 523trusted to validate signed certificates for user authentication. 524.Pp 525Certificates may encode access restrictions similar to these key options. 526If both certificate restrictions and key options are present, the most 527restrictive union of the two is applied. 528.It Cm command="command" 529Specifies that the command is executed whenever this key is used for 530authentication. 531The command supplied by the user (if any) is ignored. 532The command is run on a pty if the client requests a pty; 533otherwise it is run without a tty. 534If an 8-bit clean channel is required, 535one must not request a pty or should specify 536.Cm no-pty . 537A quote may be included in the command by quoting it with a backslash. 538This option might be useful 539to restrict certain public keys to perform just a specific operation. 540An example might be a key that permits remote backups but nothing else. 541Note that the client may specify TCP and/or X11 542forwarding unless they are explicitly prohibited. 543The command originally supplied by the client is available in the 544.Ev SSH_ORIGINAL_COMMAND 545environment variable. 546Note that this option applies to shell, command or subsystem execution. 547Also note that this command may be superseded by either a 548.Xr sshd_config 5 549.Cm ForceCommand 550directive or a command embedded in a certificate. 551.It Cm environment="NAME=value" 552Specifies that the string is to be added to the environment when 553logging in using this key. 554Environment variables set this way 555override other default environment values. 556Multiple options of this type are permitted. 557Environment processing is disabled by default and is 558controlled via the 559.Cm PermitUserEnvironment 560option. 561This option is automatically disabled if 562.Cm UseLogin 563is enabled. 564.It Cm from="pattern-list" 565Specifies that in addition to public key authentication, either the canonical 566name of the remote host or its IP address must be present in the 567comma-separated list of patterns. 568See 569.Sx PATTERNS 570in 571.Xr ssh_config 5 572for more information on patterns. 573.Pp 574In addition to the wildcard matching that may be applied to hostnames or 575addresses, a 576.Cm from 577stanza may match IP addresses using CIDR address/masklen notation. 578.Pp 579The purpose of this option is to optionally increase security: public key 580authentication by itself does not trust the network or name servers or 581anything (but the key); however, if somebody somehow steals the key, the key 582permits an intruder to log in from anywhere in the world. 583This additional option makes using a stolen key more difficult (name 584servers and/or routers would have to be compromised in addition to 585just the key). 586.It Cm no-agent-forwarding 587Forbids authentication agent forwarding when this key is used for 588authentication. 589.It Cm no-port-forwarding 590Forbids TCP forwarding when this key is used for authentication. 591Any port forward requests by the client will return an error. 592This might be used, e.g. in connection with the 593.Cm command 594option. 595.It Cm no-pty 596Prevents tty allocation (a request to allocate a pty will fail). 597.It Cm no-user-rc 598Disables execution of 599.Pa ~/.ssh/rc . 600.It Cm no-X11-forwarding 601Forbids X11 forwarding when this key is used for authentication. 602Any X11 forward requests by the client will return an error. 603.It Cm permitopen="host:port" 604Limit local 605.Li ``ssh -L'' 606port forwarding such that it may only connect to the specified host and 607port. 608IPv6 addresses can be specified by enclosing the address in square brackets. 609Multiple 610.Cm permitopen 611options may be applied separated by commas. 612No pattern matching is performed on the specified hostnames, 613they must be literal domains or addresses. 614.It Cm principals="principals" 615On a 616.Cm cert-authority 617line, specifies allowed principals for certificate authentication as a 618comma-separated list. 619At least one name from the list must appear in the certificate's 620list of principals for the certificate to be accepted. 621This option is ignored for keys that are not marked as trusted certificate 622signers using the 623.Cm cert-authority 624option. 625.It Cm tunnel="n" 626Force a 627.Xr tun 4 628device on the server. 629Without this option, the next available device will be used if 630the client requests a tunnel. 631.El 632.Pp 633An example authorized_keys file: 634.Bd -literal -offset 3n 635# Comments allowed at start of line 636ssh-rsa AAAAB3Nza...LiPk== user@example.net 637from="*.sales.example.net,!pc.sales.example.net" ssh-rsa 638AAAAB2...19Q== john@example.net 639command="dump /home",no-pty,no-port-forwarding ssh-dss 640AAAAC3...51R== example.net 641permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 642AAAAB5...21S== 643tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 644jane@example.net 645.Ed 646.Sh SSH_KNOWN_HOSTS FILE FORMAT 647The 648.Pa /etc/ssh/ssh_known_hosts 649and 650.Pa ~/.ssh/known_hosts 651files contain host public keys for all known hosts. 652The global file should 653be prepared by the administrator (optional), and the per-user file is 654maintained automatically: whenever the user connects from an unknown host, 655its key is added to the per-user file. 656.Pp 657Each line in these files contains the following fields: markers (optional), 658hostnames, bits, exponent, modulus, comment. 659The fields are separated by spaces. 660.Pp 661The marker is optional, but if it is present then it must be one of 662.Dq @cert-authority , 663to indicate that the line contains a certification authority (CA) key, 664or 665.Dq @revoked , 666to indicate that the key contained on the line is revoked and must not ever 667be accepted. 668Only one marker should be used on a key line. 669.Pp 670Hostnames is a comma-separated list of patterns 671.Pf ( Ql * 672and 673.Ql \&? 674act as 675wildcards); each pattern in turn is matched against the canonical host 676name (when authenticating a client) or against the user-supplied 677name (when authenticating a server). 678A pattern may also be preceded by 679.Ql \&! 680to indicate negation: if the host name matches a negated 681pattern, it is not accepted (by that line) even if it matched another 682pattern on the line. 683A hostname or address may optionally be enclosed within 684.Ql \&[ 685and 686.Ql \&] 687brackets then followed by 688.Ql \&: 689and a non-standard port number. 690.Pp 691Alternately, hostnames may be stored in a hashed form which hides host names 692and addresses should the file's contents be disclosed. 693Hashed hostnames start with a 694.Ql | 695character. 696Only one hashed hostname may appear on a single line and none of the above 697negation or wildcard operators may be applied. 698.Pp 699Bits, exponent, and modulus are taken directly from the RSA host key; they 700can be obtained, for example, from 701.Pa /etc/ssh/ssh_host_key.pub . 702The optional comment field continues to the end of the line, and is not used. 703.Pp 704Lines starting with 705.Ql # 706and empty lines are ignored as comments. 707.Pp 708When performing host authentication, authentication is accepted if any 709matching line has the proper key; either one that matches exactly or, 710if the server has presented a certificate for authentication, the key 711of the certification authority that signed the certificate. 712For a key to be trusted as a certification authority, it must use the 713.Dq @cert-authority 714marker described above. 715.Pp 716The known hosts file also provides a facility to mark keys as revoked, 717for example when it is known that the associated private key has been 718stolen. 719Revoked keys are specified by including the 720.Dq @revoked 721marker at the beginning of the key line, and are never accepted for 722authentication or as certification authorities, but instead will 723produce a warning from 724.Xr ssh 1 725when they are encountered. 726.Pp 727It is permissible (but not 728recommended) to have several lines or different host keys for the same 729names. 730This will inevitably happen when short forms of host names 731from different domains are put in the file. 732It is possible 733that the files contain conflicting information; authentication is 734accepted if valid information can be found from either file. 735.Pp 736Note that the lines in these files are typically hundreds of characters 737long, and you definitely don't want to type in the host keys by hand. 738Rather, generate them by a script, 739.Xr ssh-keyscan 1 740or by taking 741.Pa /etc/ssh/ssh_host_key.pub 742and adding the host names at the front. 743.Xr ssh-keygen 1 744also offers some basic automated editing for 745.Pa ~/.ssh/known_hosts 746including removing hosts matching a host name and converting all host 747names to their hashed representations. 748.Pp 749An example ssh_known_hosts file: 750.Bd -literal -offset 3n 751# Comments allowed at start of line 752closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 753cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 754# A hashed hostname 755|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 756AAAA1234.....= 757# A revoked key 758@revoked * ssh-rsa AAAAB5W... 759# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 760@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 761.Ed 762.Sh FILES 763.Bl -tag -width Ds -compact 764.It Pa ~/.hushlogin 765This file is used to suppress printing the last login time and 766.Pa /etc/motd , 767if 768.Cm PrintLastLog 769and 770.Cm PrintMotd , 771respectively, 772are enabled. 773It does not suppress printing of the banner specified by 774.Cm Banner . 775.Pp 776.It Pa ~/.rhosts 777This file is used for host-based authentication (see 778.Xr ssh 1 779for more information). 780On some machines this file may need to be 781world-readable if the user's home directory is on an NFS partition, 782because 783.Nm 784reads it as root. 785Additionally, this file must be owned by the user, 786and must not have write permissions for anyone else. 787The recommended 788permission for most machines is read/write for the user, and not 789accessible by others. 790.Pp 791.It Pa ~/.shosts 792This file is used in exactly the same way as 793.Pa .rhosts , 794but allows host-based authentication without permitting login with 795rlogin/rsh. 796.Pp 797.It Pa ~/.ssh/ 798This directory is the default location for all user-specific configuration 799and authentication information. 800There is no general requirement to keep the entire contents of this directory 801secret, but the recommended permissions are read/write/execute for the user, 802and not accessible by others. 803.Pp 804.It Pa ~/.ssh/authorized_keys 805Lists the public keys (DSA/ECDSA/RSA) that can be used for logging in 806as this user. 807The format of this file is described above. 808The content of the file is not highly sensitive, but the recommended 809permissions are read/write for the user, and not accessible by others. 810.Pp 811If this file, the 812.Pa ~/.ssh 813directory, or the user's home directory are writable 814by other users, then the file could be modified or replaced by unauthorized 815users. 816In this case, 817.Nm 818will not allow it to be used unless the 819.Cm StrictModes 820option has been set to 821.Dq no . 822.Pp 823.It Pa ~/.ssh/environment 824This file is read into the environment at login (if it exists). 825It can only contain empty lines, comment lines (that start with 826.Ql # ) , 827and assignment lines of the form name=value. 828The file should be writable 829only by the user; it need not be readable by anyone else. 830Environment processing is disabled by default and is 831controlled via the 832.Cm PermitUserEnvironment 833option. 834.Pp 835.It Pa ~/.ssh/known_hosts 836Contains a list of host keys for all hosts the user has logged into 837that are not already in the systemwide list of known host keys. 838The format of this file is described above. 839This file should be writable only by root/the owner and 840can, but need not be, world-readable. 841.Pp 842.It Pa ~/.ssh/rc 843Contains initialization routines to be run before 844the user's home directory becomes accessible. 845This file should be writable only by the user, and need not be 846readable by anyone else. 847.Pp 848.It Pa /etc/hosts.allow 849.It Pa /etc/hosts.deny 850Access controls that should be enforced by tcp-wrappers are defined here. 851Further details are described in 852.Xr hosts_access 5 . 853.Pp 854.It Pa /etc/hosts.equiv 855This file is for host-based authentication (see 856.Xr ssh 1 ) . 857It should only be writable by root. 858.Pp 859.It Pa /etc/moduli 860Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 861The file format is described in 862.Xr moduli 5 . 863.Pp 864.It Pa /etc/motd 865See 866.Xr motd 5 . 867.Pp 868.It Pa /etc/nologin 869If this file exists, 870.Nm 871refuses to let anyone except root log in. 872The contents of the file 873are displayed to anyone trying to log in, and non-root connections are 874refused. 875The file should be world-readable. 876.Pp 877.It Pa /etc/shosts.equiv 878This file is used in exactly the same way as 879.Pa hosts.equiv , 880but allows host-based authentication without permitting login with 881rlogin/rsh. 882.Pp 883.It Pa /etc/ssh/ssh_host_key 884.It Pa /etc/ssh/ssh_host_dsa_key 885.It Pa /etc/ssh/ssh_host_ecdsa_key 886.It Pa /etc/ssh/ssh_host_rsa_key 887These three files contain the private parts of the host keys. 888These files should only be owned by root, readable only by root, and not 889accessible to others. 890Note that 891.Nm 892does not start if these files are group/world-accessible. 893.Pp 894.It Pa /etc/ssh/ssh_host_key.pub 895.It Pa /etc/ssh/ssh_host_dsa_key.pub 896.It Pa /etc/ssh/ssh_host_ecdsa_key.pub 897.It Pa /etc/ssh/ssh_host_rsa_key.pub 898These three files contain the public parts of the host keys. 899These files should be world-readable but writable only by 900root. 901Their contents should match the respective private parts. 902These files are not 903really used for anything; they are provided for the convenience of 904the user so their contents can be copied to known hosts files. 905These files are created using 906.Xr ssh-keygen 1 . 907.Pp 908.It Pa /etc/ssh/ssh_known_hosts 909Systemwide list of known host keys. 910This file should be prepared by the 911system administrator to contain the public host keys of all machines in the 912organization. 913The format of this file is described above. 914This file should be writable only by root/the owner and 915should be world-readable. 916.Pp 917.It Pa /etc/ssh/sshd_config 918Contains configuration data for 919.Nm sshd . 920The file format and configuration options are described in 921.Xr sshd_config 5 . 922.Pp 923.It Pa /etc/ssh/sshrc 924Similar to 925.Pa ~/.ssh/rc , 926it can be used to specify 927machine-specific login-time initializations globally. 928This file should be writable only by root, and should be world-readable. 929.Pp 930.It Pa /var/empty 931.Xr chroot 2 932directory used by 933.Nm 934during privilege separation in the pre-authentication phase. 935The directory should not contain any files and must be owned by root 936and not group or world-writable. 937.Pp 938.It Pa /var/run/sshd.pid 939Contains the process ID of the 940.Nm 941listening for connections (if there are several daemons running 942concurrently for different ports, this contains the process ID of the one 943started last). 944The content of this file is not sensitive; it can be world-readable. 945.El 946.Sh SEE ALSO 947.Xr scp 1 , 948.Xr sftp 1 , 949.Xr ssh 1 , 950.Xr ssh-add 1 , 951.Xr ssh-agent 1 , 952.Xr ssh-keygen 1 , 953.Xr ssh-keyscan 1 , 954.Xr chroot 2 , 955.Xr hosts_access 5 , 956.Xr login.conf 5 , 957.Xr moduli 5 , 958.Xr sshd_config 5 , 959.Xr inetd 8 , 960.Xr sftp-server 8 961.Sh AUTHORS 962OpenSSH is a derivative of the original and free 963ssh 1.2.12 release by Tatu Ylonen. 964Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 965Theo de Raadt and Dug Song 966removed many bugs, re-added newer features and 967created OpenSSH. 968Markus Friedl contributed the support for SSH 969protocol versions 1.5 and 2.0. 970Niels Provos and Markus Friedl contributed support 971for privilege separation. 972.Sh CAVEATS 973System security is not improved unless 974.Nm rshd , 975.Nm rlogind , 976and 977.Nm rexecd 978are disabled (thus completely disabling 979.Xr rlogin 980and 981.Xr rsh 982into the machine). 983