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.280 2015/07/03 03:49:45 djm Exp $ 37.Dd $Mdocdate: July 3 2015 $ 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 E Ar log_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 rlogin and rsh, 64and provide secure encrypted communications between two untrusted hosts 65over an insecure network. 66.Pp 67.Nm 68listens for connections from clients. 69It is normally started at boot from 70.Pa /etc/rc . 71It forks a new 72daemon for each incoming connection. 73The forked daemons handle 74key exchange, encryption, authentication, command execution, 75and data exchange. 76.Pp 77.Nm 78can be configured using command-line options or a configuration file 79(by default 80.Xr sshd_config 5 ) ; 81command-line options override values specified in the 82configuration file. 83.Nm 84rereads its configuration file when it receives a hangup signal, 85.Dv SIGHUP , 86by executing itself with the name and options it was started with, e.g.\& 87.Pa /usr/sbin/sshd . 88.Pp 89The options are as follows: 90.Bl -tag -width Ds 91.It Fl 4 92Forces 93.Nm 94to use IPv4 addresses only. 95.It Fl 6 96Forces 97.Nm 98to use IPv6 addresses only. 99.It Fl b Ar bits 100Specifies the number of bits in the ephemeral protocol version 1 101server key (default 1024). 102.It Fl C Ar connection_spec 103Specify the connection parameters to use for the 104.Fl T 105extended test mode. 106If provided, any 107.Cm Match 108directives in the configuration file 109that would apply to the specified user, host, and address will be set before 110the configuration is written to standard output. 111The connection parameters are supplied as keyword=value pairs. 112The keywords are 113.Dq user , 114.Dq host , 115.Dq laddr , 116.Dq lport , 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 Ar log_file 148Append debug logs to 149.Ar log_file 150instead of the system log. 151.It Fl e 152Write debug logs to standard error instead of the system log. 153.It Fl f Ar config_file 154Specifies the name of the configuration file. 155The default is 156.Pa /etc/ssh/sshd_config . 157.Nm 158refuses to start if there is no configuration file. 159.It Fl g Ar login_grace_time 160Gives the grace time for clients to authenticate themselves (default 161120 seconds). 162If the client fails to authenticate the user within 163this many seconds, the server disconnects and exits. 164A value of zero indicates no limit. 165.It Fl h Ar host_key_file 166Specifies a file from which a host key is read. 167This option must be given if 168.Nm 169is not run as root (as the normal 170host key files are normally not readable by anyone but root). 171The default is 172.Pa /etc/ssh/ssh_host_key 173for protocol version 1, and 174.Pa /etc/ssh/ssh_host_dsa_key , 175.Pa /etc/ssh/ssh_host_ecdsa_key . 176.Pa /etc/ssh/ssh_host_ed25519_key 177and 178.Pa /etc/ssh/ssh_host_rsa_key 179for protocol version 2. 180It is possible to have multiple host key files for 181the different protocol versions and host key algorithms. 182.It Fl i 183Specifies that 184.Nm 185is being run from 186.Xr inetd 8 . 187If SSH protocol 1 is enabled, 188.Nm 189should not normally be run 190from inetd because it needs to generate the server key before it can 191respond to the client, and this may take some time. 192Clients may have to wait too long if the key was regenerated every time. 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, Ed25519 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 1024 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, umac-128, 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 327Regardless of the authentication type, the account is checked to 328ensure that it is accessible. An account is not accessible if it is 329locked, listed in 330.Cm DenyUsers 331or its group is listed in 332.Cm DenyGroups 333\&. The definition of a locked account is system dependant. Some platforms 334have their own account database (eg AIX) and some modify the passwd field ( 335.Ql \&*LK\&* 336on Solaris and UnixWare, 337.Ql \&* 338on HP-UX, containing 339.Ql Nologin 340on Tru64, 341a leading 342.Ql \&*LOCKED\&* 343on FreeBSD and a leading 344.Ql \&! 345on most Linuxes). 346If there is a requirement to disable password authentication 347for the account while allowing still public-key, then the passwd field 348should be set to something other than these values (eg 349.Ql NP 350or 351.Ql \&*NP\&* 352). 353.Pp 354If the client successfully authenticates itself, a dialog for 355preparing the session is entered. 356At this time the client may request 357things like allocating a pseudo-tty, forwarding X11 connections, 358forwarding TCP connections, or forwarding the authentication agent 359connection over the secure channel. 360.Pp 361After this, the client either requests a shell or execution of a command. 362The sides then enter session mode. 363In this mode, either side may send 364data at any time, and such data is forwarded to/from the shell or 365command on the server side, and the user terminal in the client side. 366.Pp 367When the user program terminates and all forwarded X11 and other 368connections have been closed, the server sends command exit status to 369the client, and both sides exit. 370.Sh LOGIN PROCESS 371When a user successfully logs in, 372.Nm 373does the following: 374.Bl -enum -offset indent 375.It 376If the login is on a tty, and no command has been specified, 377prints last login time and 378.Pa /etc/motd 379(unless prevented in the configuration file or by 380.Pa ~/.hushlogin ; 381see the 382.Sx FILES 383section). 384.It 385If the login is on a tty, records login time. 386.It 387Checks 388.Pa /etc/nologin ; 389if it exists, prints contents and quits 390(unless root). 391.It 392Changes to run with normal user privileges. 393.It 394Sets up basic environment. 395.It 396Reads the file 397.Pa ~/.ssh/environment , 398if it exists, and users are allowed to change their environment. 399See the 400.Cm PermitUserEnvironment 401option in 402.Xr sshd_config 5 . 403.It 404Changes to user's home directory. 405.It 406If 407.Pa ~/.ssh/rc 408exists and the 409.Xr sshd_config 5 410.Cm PermitUserRC 411option is set, runs it; else if 412.Pa /etc/ssh/sshrc 413exists, runs 414it; otherwise runs xauth. 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. 424All commands are run under the user's login shell as specified in the 425system password database. 426.El 427.Sh SSHRC 428If the file 429.Pa ~/.ssh/rc 430exists, 431.Xr sh 1 432runs it after reading the 433environment files but before starting the user's shell or command. 434It must not produce any output on stdout; stderr must be used 435instead. 436If X11 forwarding is in use, it will receive the "proto cookie" pair in 437its standard input (and 438.Ev DISPLAY 439in its environment). 440The script must call 441.Xr xauth 1 442because 443.Nm 444will not run xauth automatically to add X11 cookies. 445.Pp 446The primary purpose of this file is to run any initialization routines 447which may be needed before the user's home directory becomes 448accessible; AFS is a particular example of such an environment. 449.Pp 450This file will probably contain some initialization code followed by 451something similar to: 452.Bd -literal -offset 3n 453if read proto cookie && [ -n "$DISPLAY" ]; then 454 if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then 455 # X11UseLocalhost=yes 456 echo add unix:`echo $DISPLAY | 457 cut -c11-` $proto $cookie 458 else 459 # X11UseLocalhost=no 460 echo add $DISPLAY $proto $cookie 461 fi | xauth -q - 462fi 463.Ed 464.Pp 465If this file does not exist, 466.Pa /etc/ssh/sshrc 467is run, and if that 468does not exist either, xauth is used to add the cookie. 469.Sh AUTHORIZED_KEYS FILE FORMAT 470.Cm AuthorizedKeysFile 471specifies the files containing public keys for 472public key authentication; 473if none is specified, the default is 474.Pa ~/.ssh/authorized_keys 475and 476.Pa ~/.ssh/authorized_keys2 . 477Each line of the file contains one 478key (empty lines and lines starting with a 479.Ql # 480are ignored as 481comments). 482Protocol 1 public keys consist of the following space-separated fields: 483options, bits, exponent, modulus, comment. 484Protocol 2 public key consist of: 485options, keytype, base64-encoded key, comment. 486The options field is optional; 487its presence is determined by whether the line starts 488with a number or not (the options field never starts with a number). 489The bits, exponent, modulus, and comment fields give the RSA key for 490protocol version 1; the 491comment field is not used for anything (but may be convenient for the 492user to identify the key). 493For protocol version 2 the keytype is 494.Dq ecdsa-sha2-nistp256 , 495.Dq ecdsa-sha2-nistp384 , 496.Dq ecdsa-sha2-nistp521 , 497.Dq ssh-ed25519 , 498.Dq ssh-dss 499or 500.Dq ssh-rsa . 501.Pp 502Note that lines in this file are usually several hundred bytes long 503(because of the size of the public key encoding) up to a limit of 5048 kilobytes, which permits DSA keys up to 8 kilobits and RSA 505keys up to 16 kilobits. 506You don't want to type them in; instead, copy the 507.Pa identity.pub , 508.Pa id_dsa.pub , 509.Pa id_ecdsa.pub , 510.Pa id_ed25519.pub , 511or the 512.Pa id_rsa.pub 513file and edit it. 514.Pp 515.Nm 516enforces a minimum RSA key modulus size for protocol 1 517and protocol 2 keys of 768 bits. 518.Pp 519The options (if present) consist of comma-separated option 520specifications. 521No spaces are permitted, except within double quotes. 522The following option specifications are supported (note 523that option keywords are case-insensitive): 524.Bl -tag -width Ds 525.It Cm cert-authority 526Specifies that the listed key is a certification authority (CA) that is 527trusted to validate signed certificates for user authentication. 528.Pp 529Certificates may encode access restrictions similar to these key options. 530If both certificate restrictions and key options are present, the most 531restrictive union of the two is applied. 532.It Cm command="command" 533Specifies that the command is executed whenever this key is used for 534authentication. 535The command supplied by the user (if any) is ignored. 536The command is run on a pty if the client requests a pty; 537otherwise it is run without a tty. 538If an 8-bit clean channel is required, 539one must not request a pty or should specify 540.Cm no-pty . 541A quote may be included in the command by quoting it with a backslash. 542This option might be useful 543to restrict certain public keys to perform just a specific operation. 544An example might be a key that permits remote backups but nothing else. 545Note that the client may specify TCP and/or X11 546forwarding unless they are explicitly prohibited. 547The command originally supplied by the client is available in the 548.Ev SSH_ORIGINAL_COMMAND 549environment variable. 550Note that this option applies to shell, command or subsystem execution. 551Also note that this command may be superseded by either a 552.Xr sshd_config 5 553.Cm ForceCommand 554directive or a command embedded in a certificate. 555.It Cm environment="NAME=value" 556Specifies that the string is to be added to the environment when 557logging in using this key. 558Environment variables set this way 559override other default environment values. 560Multiple options of this type are permitted. 561Environment processing is disabled by default and is 562controlled via the 563.Cm PermitUserEnvironment 564option. 565This option is automatically disabled if 566.Cm UseLogin 567is enabled. 568.It Cm from="pattern-list" 569Specifies that in addition to public key authentication, either the canonical 570name of the remote host or its IP address must be present in the 571comma-separated list of patterns. 572See PATTERNS in 573.Xr ssh_config 5 574for more information on patterns. 575.Pp 576In addition to the wildcard matching that may be applied to hostnames or 577addresses, a 578.Cm from 579stanza may match IP addresses using CIDR address/masklen notation. 580.Pp 581The purpose of this option is to optionally increase security: public key 582authentication by itself does not trust the network or name servers or 583anything (but the key); however, if somebody somehow steals the key, the key 584permits an intruder to log in from anywhere in the world. 585This additional option makes using a stolen key more difficult (name 586servers and/or routers would have to be compromised in addition to 587just the key). 588.It Cm no-agent-forwarding 589Forbids authentication agent forwarding when this key is used for 590authentication. 591.It Cm no-port-forwarding 592Forbids TCP forwarding when this key is used for authentication. 593Any port forward requests by the client will return an error. 594This might be used, e.g. in connection with the 595.Cm command 596option. 597.It Cm no-pty 598Prevents tty allocation (a request to allocate a pty will fail). 599.It Cm no-user-rc 600Disables execution of 601.Pa ~/.ssh/rc . 602.It Cm no-X11-forwarding 603Forbids X11 forwarding when this key is used for authentication. 604Any X11 forward requests by the client will return an error. 605.It Cm permitopen="host:port" 606Limit local port forwarding with 607.Xr ssh 1 608.Fl L 609such that it may only connect to the specified host and port. 610IPv6 addresses can be specified by enclosing the address in square brackets. 611Multiple 612.Cm permitopen 613options may be applied separated by commas. 614No pattern matching is performed on the specified hostnames, 615they must be literal domains or addresses. 616A port specification of 617.Cm * 618matches any port. 619.It Cm principals="principals" 620On a 621.Cm cert-authority 622line, specifies allowed principals for certificate authentication as a 623comma-separated list. 624At least one name from the list must appear in the certificate's 625list of principals for the certificate to be accepted. 626This option is ignored for keys that are not marked as trusted certificate 627signers using the 628.Cm cert-authority 629option. 630.It Cm tunnel="n" 631Force a 632.Xr tun 4 633device on the server. 634Without this option, the next available device will be used if 635the client requests a tunnel. 636.El 637.Pp 638An example authorized_keys file: 639.Bd -literal -offset 3n 640# Comments allowed at start of line 641ssh-rsa AAAAB3Nza...LiPk== user@example.net 642from="*.sales.example.net,!pc.sales.example.net" ssh-rsa 643AAAAB2...19Q== john@example.net 644command="dump /home",no-pty,no-port-forwarding ssh-dss 645AAAAC3...51R== example.net 646permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss 647AAAAB5...21S== 648tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...== 649jane@example.net 650.Ed 651.Sh SSH_KNOWN_HOSTS FILE FORMAT 652The 653.Pa /etc/ssh/ssh_known_hosts 654and 655.Pa ~/.ssh/known_hosts 656files contain host public keys for all known hosts. 657The global file should 658be prepared by the administrator (optional), and the per-user file is 659maintained automatically: whenever the user connects from an unknown host, 660its key is added to the per-user file. 661.Pp 662Each line in these files contains the following fields: markers (optional), 663hostnames, bits, exponent, modulus, comment. 664The fields are separated by spaces. 665.Pp 666The marker is optional, but if it is present then it must be one of 667.Dq @cert-authority , 668to indicate that the line contains a certification authority (CA) key, 669or 670.Dq @revoked , 671to indicate that the key contained on the line is revoked and must not ever 672be accepted. 673Only one marker should be used on a key line. 674.Pp 675Hostnames is a comma-separated list of patterns 676.Pf ( Ql * 677and 678.Ql \&? 679act as 680wildcards); each pattern in turn is matched against the canonical host 681name (when authenticating a client) or against the user-supplied 682name (when authenticating a server). 683A pattern may also be preceded by 684.Ql \&! 685to indicate negation: if the host name matches a negated 686pattern, it is not accepted (by that line) even if it matched another 687pattern on the line. 688A hostname or address may optionally be enclosed within 689.Ql \&[ 690and 691.Ql \&] 692brackets then followed by 693.Ql \&: 694and a non-standard port number. 695.Pp 696Alternately, hostnames may be stored in a hashed form which hides host names 697and addresses should the file's contents be disclosed. 698Hashed hostnames start with a 699.Ql | 700character. 701Only one hashed hostname may appear on a single line and none of the above 702negation or wildcard operators may be applied. 703.Pp 704Bits, exponent, and modulus are taken directly from the RSA host key; they 705can be obtained, for example, from 706.Pa /etc/ssh/ssh_host_key.pub . 707The optional comment field continues to the end of the line, and is not used. 708.Pp 709Lines starting with 710.Ql # 711and empty lines are ignored as comments. 712.Pp 713When performing host authentication, authentication is accepted if any 714matching line has the proper key; either one that matches exactly or, 715if the server has presented a certificate for authentication, the key 716of the certification authority that signed the certificate. 717For a key to be trusted as a certification authority, it must use the 718.Dq @cert-authority 719marker described above. 720.Pp 721The known hosts file also provides a facility to mark keys as revoked, 722for example when it is known that the associated private key has been 723stolen. 724Revoked keys are specified by including the 725.Dq @revoked 726marker at the beginning of the key line, and are never accepted for 727authentication or as certification authorities, but instead will 728produce a warning from 729.Xr ssh 1 730when they are encountered. 731.Pp 732It is permissible (but not 733recommended) to have several lines or different host keys for the same 734names. 735This will inevitably happen when short forms of host names 736from different domains are put in the file. 737It is possible 738that the files contain conflicting information; authentication is 739accepted if valid information can be found from either file. 740.Pp 741Note that the lines in these files are typically hundreds of characters 742long, and you definitely don't want to type in the host keys by hand. 743Rather, generate them by a script, 744.Xr ssh-keyscan 1 745or by taking 746.Pa /etc/ssh/ssh_host_key.pub 747and adding the host names at the front. 748.Xr ssh-keygen 1 749also offers some basic automated editing for 750.Pa ~/.ssh/known_hosts 751including removing hosts matching a host name and converting all host 752names to their hashed representations. 753.Pp 754An example ssh_known_hosts file: 755.Bd -literal -offset 3n 756# Comments allowed at start of line 757closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net 758cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....= 759# A hashed hostname 760|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa 761AAAA1234.....= 762# A revoked key 763@revoked * ssh-rsa AAAAB5W... 764# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org 765@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W... 766.Ed 767.Sh FILES 768.Bl -tag -width Ds -compact 769.It Pa ~/.hushlogin 770This file is used to suppress printing the last login time and 771.Pa /etc/motd , 772if 773.Cm PrintLastLog 774and 775.Cm PrintMotd , 776respectively, 777are enabled. 778It does not suppress printing of the banner specified by 779.Cm Banner . 780.Pp 781.It Pa ~/.rhosts 782This file is used for host-based authentication (see 783.Xr ssh 1 784for more information). 785On some machines this file may need to be 786world-readable if the user's home directory is on an NFS partition, 787because 788.Nm 789reads it as root. 790Additionally, this file must be owned by the user, 791and must not have write permissions for anyone else. 792The recommended 793permission for most machines is read/write for the user, and not 794accessible by others. 795.Pp 796.It Pa ~/.shosts 797This file is used in exactly the same way as 798.Pa .rhosts , 799but allows host-based authentication without permitting login with 800rlogin/rsh. 801.Pp 802.It Pa ~/.ssh/ 803This directory is the default location for all user-specific configuration 804and authentication information. 805There is no general requirement to keep the entire contents of this directory 806secret, but the recommended permissions are read/write/execute for the user, 807and not accessible by others. 808.Pp 809.It Pa ~/.ssh/authorized_keys 810Lists the public keys (DSA, ECDSA, Ed25519, RSA) 811that can be used for logging in as this user. 812The format of this file is described above. 813The content of the file is not highly sensitive, but the recommended 814permissions are read/write for the user, and not accessible by others. 815.Pp 816If this file, the 817.Pa ~/.ssh 818directory, or the user's home directory are writable 819by other users, then the file could be modified or replaced by unauthorized 820users. 821In this case, 822.Nm 823will not allow it to be used unless the 824.Cm StrictModes 825option has been set to 826.Dq no . 827.Pp 828.It Pa ~/.ssh/environment 829This file is read into the environment at login (if it exists). 830It can only contain empty lines, comment lines (that start with 831.Ql # ) , 832and assignment lines of the form name=value. 833The file should be writable 834only by the user; it need not be readable by anyone else. 835Environment processing is disabled by default and is 836controlled via the 837.Cm PermitUserEnvironment 838option. 839.Pp 840.It Pa ~/.ssh/known_hosts 841Contains a list of host keys for all hosts the user has logged into 842that are not already in the systemwide list of known host keys. 843The format of this file is described above. 844This file should be writable only by root/the owner and 845can, but need not be, world-readable. 846.Pp 847.It Pa ~/.ssh/rc 848Contains initialization routines to be run before 849the user's home directory becomes accessible. 850This file should be writable only by the user, and need not be 851readable by anyone else. 852.Pp 853.It Pa /etc/hosts.equiv 854This file is for host-based authentication (see 855.Xr ssh 1 ) . 856It should only be writable by root. 857.Pp 858.It Pa /etc/moduli 859Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange". 860The file format is described in 861.Xr moduli 5 . 862.Pp 863.It Pa /etc/motd 864See 865.Xr motd 5 . 866.Pp 867.It Pa /etc/nologin 868If this file exists, 869.Nm 870refuses to let anyone except root log in. 871The contents of the file 872are displayed to anyone trying to log in, and non-root connections are 873refused. 874The file should be world-readable. 875.Pp 876.It Pa /etc/shosts.equiv 877This file is used in exactly the same way as 878.Pa hosts.equiv , 879but allows host-based authentication without permitting login with 880rlogin/rsh. 881.Pp 882.It Pa /etc/ssh/ssh_host_key 883.It Pa /etc/ssh/ssh_host_dsa_key 884.It Pa /etc/ssh/ssh_host_ecdsa_key 885.It Pa /etc/ssh/ssh_host_ed25519_key 886.It Pa /etc/ssh/ssh_host_rsa_key 887These 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_ed25519_key.pub 898.It Pa /etc/ssh/ssh_host_rsa_key.pub 899These files contain the public parts of the host keys. 900These files should be world-readable but writable only by 901root. 902Their contents should match the respective private parts. 903These files are not 904really used for anything; they are provided for the convenience of 905the user so their contents can be copied to known hosts files. 906These files are created using 907.Xr ssh-keygen 1 . 908.Pp 909.It Pa /etc/ssh/ssh_known_hosts 910Systemwide list of known host keys. 911This file should be prepared by the 912system administrator to contain the public host keys of all machines in the 913organization. 914The format of this file is described above. 915This file should be writable only by root/the owner and 916should be world-readable. 917.Pp 918.It Pa /etc/ssh/sshd_config 919Contains configuration data for 920.Nm sshd . 921The file format and configuration options are described in 922.Xr sshd_config 5 . 923.Pp 924.It Pa /etc/ssh/sshrc 925Similar to 926.Pa ~/.ssh/rc , 927it can be used to specify 928machine-specific login-time initializations globally. 929This file should be writable only by root, and should be world-readable. 930.Pp 931.It Pa /var/empty 932.Xr chroot 2 933directory used by 934.Nm 935during privilege separation in the pre-authentication phase. 936The directory should not contain any files and must be owned by root 937and not group or world-writable. 938.Pp 939.It Pa /var/run/sshd.pid 940Contains the process ID of the 941.Nm 942listening for connections (if there are several daemons running 943concurrently for different ports, this contains the process ID of the one 944started last). 945The content of this file is not sensitive; it can be world-readable. 946.El 947.Sh SEE ALSO 948.Xr scp 1 , 949.Xr sftp 1 , 950.Xr ssh 1 , 951.Xr ssh-add 1 , 952.Xr ssh-agent 1 , 953.Xr ssh-keygen 1 , 954.Xr ssh-keyscan 1 , 955.Xr chroot 2 , 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