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