1.\" -*- nroff -*- 2.\" 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 5.\" All rights reserved 6.\" 7.\" As far as I am concerned, the code I have written for this software 8.\" can be used freely for any purpose. Any derived versions of this 9.\" software must be clearly marked as such, and if the derived work is 10.\" incompatible with the protocol description in the RFC file, it must be 11.\" called by a name other than "ssh" or "Secure Shell". 12.\" 13.\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved. 14.\" Copyright (c) 1999 Aaron Campbell. All rights reserved. 15.\" Copyright (c) 1999 Theo de Raadt. All rights reserved. 16.\" 17.\" Redistribution and use in source and binary forms, with or without 18.\" modification, are permitted provided that the following conditions 19.\" are met: 20.\" 1. Redistributions of source code must retain the above copyright 21.\" notice, this list of conditions and the following disclaimer. 22.\" 2. Redistributions in binary form must reproduce the above copyright 23.\" notice, this list of conditions and the following disclaimer in the 24.\" documentation and/or other materials provided with the distribution. 25.\" 26.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 27.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 30.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" 37.\" $OpenBSD: ssh.1,v 1.167 2002/09/27 15:46:21 stevesk Exp $ 38.\" $FreeBSD$ 39.Dd September 25, 1999 40.Dt SSH 1 41.Os 42.Sh NAME 43.Nm ssh 44.Nd OpenSSH SSH client (remote login program) 45.Sh SYNOPSIS 46.Nm ssh 47.Op Fl l Ar login_name 48.Ar hostname | user@hostname 49.Op Ar command 50.Pp 51.Nm ssh 52.Op Fl afgknqstvxACNTX1246 53.Op Fl b Ar bind_address 54.Op Fl c Ar cipher_spec 55.Op Fl e Ar escape_char 56.Op Fl i Ar identity_file 57.Op Fl l Ar login_name 58.Op Fl m Ar mac_spec 59.Op Fl o Ar option 60.Op Fl p Ar port 61.Op Fl F Ar configfile 62.Oo Fl L Xo 63.Sm off 64.Ar port : 65.Ar host : 66.Ar hostport 67.Sm on 68.Xc 69.Oc 70.Oo Fl R Xo 71.Sm off 72.Ar port : 73.Ar host : 74.Ar hostport 75.Sm on 76.Xc 77.Oc 78.Op Fl D Ar port 79.Ar hostname | user@hostname 80.Op Ar command 81.Sh DESCRIPTION 82.Nm 83(SSH client) is a program for logging into a remote machine and for 84executing commands on a remote machine. 85It is intended to replace 86rlogin and rsh, and provide secure encrypted communications between 87two untrusted hosts over an insecure network. 88X11 connections and 89arbitrary TCP/IP ports can also be forwarded over the secure channel. 90.Pp 91.Nm 92connects and logs into the specified 93.Ar hostname . 94The user must prove 95his/her identity to the remote machine using one of several methods 96depending on the protocol version used: 97.Pp 98.Ss SSH protocol version 1 99.Pp 100First, if the machine the user logs in from is listed in 101.Pa /etc/hosts.equiv 102or 103.Pa /etc/ssh/shosts.equiv 104on the remote machine, and the user names are 105the same on both sides, the user is immediately permitted to log in. 106Second, if 107.Pa \&.rhosts 108or 109.Pa \&.shosts 110exists in the user's home directory on the 111remote machine and contains a line containing the name of the client 112machine and the name of the user on that machine, the user is 113permitted to log in. 114This form of authentication alone is normally not 115allowed by the server because it is not secure. 116.Pp 117The second authentication method is the 118.Pa rhosts 119or 120.Pa hosts.equiv 121method combined with RSA-based host authentication. 122It means that if the login would be permitted by 123.Pa $HOME/.rhosts , 124.Pa $HOME/.shosts , 125.Pa /etc/hosts.equiv , 126or 127.Pa /etc/ssh/shosts.equiv , 128and if additionally the server can verify the client's 129host key (see 130.Pa /etc/ssh/ssh_known_hosts 131and 132.Pa $HOME/.ssh/known_hosts 133in the 134.Sx FILES 135section), only then login is permitted. 136This authentication method closes security holes due to IP 137spoofing, DNS spoofing and routing spoofing. 138[Note to the administrator: 139.Pa /etc/hosts.equiv , 140.Pa $HOME/.rhosts , 141and the rlogin/rsh protocol in general, are inherently insecure and should be 142disabled if security is desired.] 143.Pp 144As a third authentication method, 145.Nm 146supports RSA based authentication. 147The scheme is based on public-key cryptography: there are cryptosystems 148where encryption and decryption are done using separate keys, and it 149is not possible to derive the decryption key from the encryption key. 150RSA is one such system. 151The idea is that each user creates a public/private 152key pair for authentication purposes. 153The server knows the public key, and only the user knows the private key. 154The file 155.Pa $HOME/.ssh/authorized_keys 156lists the public keys that are permitted for logging 157in. 158When the user logs in, the 159.Nm 160program tells the server which key pair it would like to use for 161authentication. 162The server checks if this key is permitted, and if 163so, sends the user (actually the 164.Nm 165program running on behalf of the user) a challenge, a random number, 166encrypted by the user's public key. 167The challenge can only be 168decrypted using the proper private key. 169The user's client then decrypts the 170challenge using the private key, proving that he/she knows the private 171key but without disclosing it to the server. 172.Pp 173.Nm 174implements the RSA authentication protocol automatically. 175The user creates his/her RSA key pair by running 176.Xr ssh-keygen 1 . 177This stores the private key in 178.Pa $HOME/.ssh/identity 179and the public key in 180.Pa $HOME/.ssh/identity.pub 181in the user's home directory. 182The user should then copy the 183.Pa identity.pub 184to 185.Pa $HOME/.ssh/authorized_keys 186in his/her home directory on the remote machine (the 187.Pa authorized_keys 188file corresponds to the conventional 189.Pa $HOME/.rhosts 190file, and has one key 191per line, though the lines can be very long). 192After this, the user can log in without giving the password. 193RSA authentication is much 194more secure than rhosts authentication. 195.Pp 196The most convenient way to use RSA authentication may be with an 197authentication agent. 198See 199.Xr ssh-agent 1 200for more information. 201.Pp 202If other authentication methods fail, 203.Nm 204prompts the user for a password. 205The password is sent to the remote 206host for checking; however, since all communications are encrypted, 207the password cannot be seen by someone listening on the network. 208.Pp 209.Ss SSH protocol version 2 210.Pp 211When a user connects using protocol version 2 212similar authentication methods are available. 213Using the default values for 214.Cm PreferredAuthentications , 215the client will try to authenticate first using the hostbased method; 216if this method fails public key authentication is attempted, 217and finally if this method fails keyboard-interactive and 218password authentication are tried. 219.Pp 220The public key method is similar to RSA authentication described 221in the previous section and allows the RSA or DSA algorithm to be used: 222The client uses his private key, 223.Pa $HOME/.ssh/id_dsa 224or 225.Pa $HOME/.ssh/id_rsa , 226to sign the session identifier and sends the result to the server. 227The server checks whether the matching public key is listed in 228.Pa $HOME/.ssh/authorized_keys 229and grants access if both the key is found and the signature is correct. 230The session identifier is derived from a shared Diffie-Hellman value 231and is only known to the client and the server. 232.Pp 233If public key authentication fails or is not available a password 234can be sent encrypted to the remote host for proving the user's identity. 235.Pp 236Additionally, 237.Nm 238supports hostbased or challenge response authentication. 239.Pp 240Protocol 2 provides additional mechanisms for confidentiality 241(the traffic is encrypted using 3DES, Blowfish, CAST128 or Arcfour) 242and integrity (hmac-md5, hmac-sha1). 243Note that protocol 1 lacks a strong mechanism for ensuring the 244integrity of the connection. 245.Pp 246.Ss Login session and remote execution 247.Pp 248When the user's identity has been accepted by the server, the server 249either executes the given command, or logs into the machine and gives 250the user a normal shell on the remote machine. 251All communication with 252the remote command or shell will be automatically encrypted. 253.Pp 254If a pseudo-terminal has been allocated (normal login session), the 255user may use the escape characters noted below. 256.Pp 257If no pseudo tty has been allocated, the 258session is transparent and can be used to reliably transfer binary 259data. 260On most systems, setting the escape character to 261.Dq none 262will also make the session transparent even if a tty is used. 263.Pp 264The session terminates when the command or shell on the remote 265machine exits and all X11 and TCP/IP connections have been closed. 266The exit status of the remote program is returned as the exit status 267of 268.Nm ssh . 269.Pp 270.Ss Escape Characters 271.Pp 272When a pseudo terminal has been requested, ssh supports a number of functions 273through the use of an escape character. 274.Pp 275A single tilde character can be sent as 276.Ic ~~ 277or by following the tilde by a character other than those described below. 278The escape character must always follow a newline to be interpreted as 279special. 280The escape character can be changed in configuration files using the 281.Cm EscapeChar 282configuration directive or on the command line by the 283.Fl e 284option. 285.Pp 286The supported escapes (assuming the default 287.Ql ~ ) 288are: 289.Bl -tag -width Ds 290.It Cm ~. 291Disconnect 292.It Cm ~^Z 293Background ssh 294.It Cm ~# 295List forwarded connections 296.It Cm ~& 297Background ssh at logout when waiting for forwarded connection / X11 sessions 298to terminate 299.It Cm ~? 300Display a list of escape characters 301.It Cm ~C 302Open command line (only useful for adding port forwardings using the 303.Fl L 304and 305.Fl R 306options) 307.It Cm ~R 308Request rekeying of the connection (only useful for SSH protocol version 2 309and if the peer supports it) 310.El 311.Pp 312.Ss X11 and TCP forwarding 313.Pp 314If the 315.Cm ForwardX11 316variable is set to 317.Dq yes 318(or, see the description of the 319.Fl X 320and 321.Fl x 322options described later) 323and the user is using X11 (the 324.Ev DISPLAY 325environment variable is set), the connection to the X11 display is 326automatically forwarded to the remote side in such a way that any X11 327programs started from the shell (or command) will go through the 328encrypted channel, and the connection to the real X server will be made 329from the local machine. 330The user should not manually set 331.Ev DISPLAY . 332Forwarding of X11 connections can be 333configured on the command line or in configuration files. 334Take note that X11 forwarding can represent a security hazard. 335.Pp 336The 337.Ev DISPLAY 338value set by 339.Nm 340will point to the server machine, but with a display number greater 341than zero. 342This is normal, and happens because 343.Nm 344creates a 345.Dq proxy 346X server on the server machine for forwarding the 347connections over the encrypted channel. 348.Pp 349.Nm 350will also automatically set up Xauthority data on the server machine. 351For this purpose, it will generate a random authorization cookie, 352store it in Xauthority on the server, and verify that any forwarded 353connections carry this cookie and replace it by the real cookie when 354the connection is opened. 355The real authentication cookie is never 356sent to the server machine (and no cookies are sent in the plain). 357.Pp 358If the 359.Cm ForwardAgent 360variable is set to 361.Dq yes 362(or, see the description of the 363.Fl A 364and 365.Fl a 366options described later) and 367the user is using an authentication agent, the connection to the agent 368is automatically forwarded to the remote side. 369.Pp 370Forwarding of arbitrary TCP/IP connections over the secure channel can 371be specified either on the command line or in a configuration file. 372One possible application of TCP/IP forwarding is a secure connection to an 373electronic purse; another is going through firewalls. 374.Pp 375.Ss Server authentication 376.Pp 377.Nm 378automatically maintains and checks a database containing 379identifications for all hosts it has ever been used with. 380Host keys are stored in 381.Pa $HOME/.ssh/known_hosts 382in the user's home directory. 383Additionally, the file 384.Pa /etc/ssh/ssh_known_hosts 385is automatically checked for known hosts. 386Any new hosts are automatically added to the user's file. 387If a host's identification 388ever changes, 389.Nm 390warns about this and disables password authentication to prevent a 391trojan horse from getting the user's password. 392Another purpose of 393this mechanism is to prevent man-in-the-middle attacks which could 394otherwise be used to circumvent the encryption. 395The 396.Cm StrictHostKeyChecking 397option can be used to prevent logins to machines whose 398host key is not known or has changed. 399.Pp 400The options are as follows: 401.Bl -tag -width Ds 402.It Fl a 403Disables forwarding of the authentication agent connection. 404.It Fl A 405Enables forwarding of the authentication agent connection. 406This can also be specified on a per-host basis in a configuration file. 407.Pp 408Agent forwarding should be enabled with caution. Users with the 409ability to bypass file permissions on the remote host (for the agent's 410Unix-domain socket) can access the local agent through the forwarded 411connection. An attacker cannot obtain key material from the agent, 412however they can perform operations on the keys that enable them to 413authenticate using the identities loaded into the agent. 414.It Fl b Ar bind_address 415Specify the interface to transmit from on machines with multiple 416interfaces or aliased addresses. 417.It Fl c Ar blowfish|3des|des 418Selects the cipher to use for encrypting the session. 419.Ar 3des 420is used by default. 421It is believed to be secure. 422.Ar 3des 423(triple-des) is an encrypt-decrypt-encrypt triple with three different keys. 424.Ar blowfish 425is a fast block cipher, it appears very secure and is much faster than 426.Ar 3des . 427.Ar des 428is only supported in the 429.Nm 430client for interoperability with legacy protocol 1 implementations 431that do not support the 432.Ar 3des 433cipher. Its use is strongly discouraged due to cryptographic 434weaknesses. 435.It Fl c Ar cipher_spec 436Additionally, for protocol version 2 a comma-separated list of ciphers can 437be specified in order of preference. 438See 439.Cm Ciphers 440for more information. 441.It Fl e Ar ch|^ch|none 442Sets the escape character for sessions with a pty (default: 443.Ql ~ ) . 444The escape character is only recognized at the beginning of a line. 445The escape character followed by a dot 446.Pq Ql \&. 447closes the connection, followed 448by control-Z suspends the connection, and followed by itself sends the 449escape character once. 450Setting the character to 451.Dq none 452disables any escapes and makes the session fully transparent. 453.It Fl f 454Requests 455.Nm 456to go to background just before command execution. 457This is useful if 458.Nm 459is going to ask for passwords or passphrases, but the user 460wants it in the background. 461This implies 462.Fl n . 463The recommended way to start X11 programs at a remote site is with 464something like 465.Ic ssh -f host xterm . 466.It Fl g 467Allows remote hosts to connect to local forwarded ports. 468.It Fl i Ar identity_file 469Selects a file from which the identity (private key) for 470RSA or DSA authentication is read. 471The default is 472.Pa $HOME/.ssh/identity 473for protocol version 1, and 474.Pa $HOME/.ssh/id_rsa 475and 476.Pa $HOME/.ssh/id_dsa 477for protocol version 2. 478Identity files may also be specified on 479a per-host basis in the configuration file. 480It is possible to have multiple 481.Fl i 482options (and multiple identities specified in 483configuration files). 484.It Fl I Ar smartcard_device 485Specifies which smartcard device to use. The argument is 486the device 487.Nm 488should use to communicate with a smartcard used for storing the user's 489private RSA key. 490.It Fl k 491Disables forwarding of Kerberos tickets and AFS tokens. 492This may also be specified on a per-host basis in the configuration file. 493.It Fl l Ar login_name 494Specifies the user to log in as on the remote machine. 495This also may be specified on a per-host basis in the configuration file. 496.It Fl m Ar mac_spec 497Additionally, for protocol version 2 a comma-separated list of MAC 498(message authentication code) algorithms can 499be specified in order of preference. 500See the 501.Cm MACs 502keyword for more information. 503.It Fl n 504Redirects stdin from 505.Pa /dev/null 506(actually, prevents reading from stdin). 507This must be used when 508.Nm 509is run in the background. 510A common trick is to use this to run X11 programs on a remote machine. 511For example, 512.Ic ssh -n shadows.cs.hut.fi emacs & 513will start an emacs on shadows.cs.hut.fi, and the X11 514connection will be automatically forwarded over an encrypted channel. 515The 516.Nm 517program will be put in the background. 518(This does not work if 519.Nm 520needs to ask for a password or passphrase; see also the 521.Fl f 522option.) 523.It Fl N 524Do not execute a remote command. 525This is useful for just forwarding ports 526(protocol version 2 only). 527.It Fl o Ar option 528Can be used to give options in the format used in the configuration file. 529This is useful for specifying options for which there is no separate 530command-line flag. 531.It Fl p Ar port 532Port to connect to on the remote host. 533This can be specified on a 534per-host basis in the configuration file. 535.It Fl q 536Quiet mode. 537Causes all warning and diagnostic messages to be suppressed. 538.It Fl s 539May be used to request invocation of a subsystem on the remote system. Subsystems are a feature of the SSH2 protocol which facilitate the use 540of SSH as a secure transport for other applications (eg. sftp). The 541subsystem is specified as the remote command. 542.It Fl t 543Force pseudo-tty allocation. 544This can be used to execute arbitrary 545screen-based programs on a remote machine, which can be very useful, 546e.g., when implementing menu services. 547Multiple 548.Fl t 549options force tty allocation, even if 550.Nm 551has no local tty. 552.It Fl T 553Disable pseudo-tty allocation. 554.It Fl v 555Verbose mode. 556Causes 557.Nm 558to print debugging messages about its progress. 559This is helpful in 560debugging connection, authentication, and configuration problems. 561Multiple 562.Fl v 563options increases the verbosity. 564Maximum is 3. 565.It Fl x 566Disables X11 forwarding. 567.It Fl X 568Enables X11 forwarding. 569This can also be specified on a per-host basis in a configuration file. 570.Pp 571X11 forwarding should be enabled with caution. Users with the ability 572to bypass file permissions on the remote host (for the user's X 573authorization database) can access the local X11 display through the 574forwarded connection. An attacker may then be able to perform 575activities such as keystroke monitoring. 576.It Fl C 577Requests compression of all data (including stdin, stdout, stderr, and 578data for forwarded X11 and TCP/IP connections). 579The compression algorithm is the same used by 580.Xr gzip 1 , 581and the 582.Dq level 583can be controlled by the 584.Cm CompressionLevel 585option for protocol version 1. 586Compression is desirable on modem lines and other 587slow connections, but will only slow down things on fast networks. 588The default value can be set on a host-by-host basis in the 589configuration files; see the 590.Cm Compression 591option. 592.It Fl F Ar configfile 593Specifies an alternative per-user configuration file. 594If a configuration file is given on the command line, 595the system-wide configuration file 596.Pq Pa /etc/ssh/ssh_config 597will be ignored. 598The default for the per-user configuration file is 599.Pa $HOME/.ssh/config . 600.It Fl L Ar port:host:hostport 601Specifies that the given port on the local (client) host is to be 602forwarded to the given host and port on the remote side. 603This works by allocating a socket to listen to 604.Ar port 605on the local side, and whenever a connection is made to this port, the 606connection is forwarded over the secure channel, and a connection is 607made to 608.Ar host 609port 610.Ar hostport 611from the remote machine. 612Port forwardings can also be specified in the configuration file. 613Only root can forward privileged ports. 614IPv6 addresses can be specified with an alternative syntax: 615.Ar port/host/hostport 616.It Fl R Ar port:host:hostport 617Specifies that the given port on the remote (server) host is to be 618forwarded to the given host and port on the local side. 619This works by allocating a socket to listen to 620.Ar port 621on the remote side, and whenever a connection is made to this port, the 622connection is forwarded over the secure channel, and a connection is 623made to 624.Ar host 625port 626.Ar hostport 627from the local machine. 628Port forwardings can also be specified in the configuration file. 629Privileged ports can be forwarded only when 630logging in as root on the remote machine. 631IPv6 addresses can be specified with an alternative syntax: 632.Ar port/host/hostport 633.It Fl D Ar port 634Specifies a local 635.Dq dynamic 636application-level port forwarding. 637This works by allocating a socket to listen to 638.Ar port 639on the local side, and whenever a connection is made to this port, the 640connection is forwarded over the secure channel, and the application 641protocol is then used to determine where to connect to from the 642remote machine. Currently the SOCKS4 protocol is supported, and 643.Nm 644will act as a SOCKS4 server. 645Only root can forward privileged ports. 646Dynamic port forwardings can also be specified in the configuration file. 647.It Fl 1 648Forces 649.Nm 650to try protocol version 1 only. 651.It Fl 2 652Forces 653.Nm 654to try protocol version 2 only. 655.It Fl 4 656Forces 657.Nm 658to use IPv4 addresses only. 659.It Fl 6 660Forces 661.Nm 662to use IPv6 addresses only. 663.El 664.Sh CONFIGURATION FILES 665.Nm 666may additionally obtain configuration data from 667a per-user configuration file and a system-wide configuration file. 668The file format and configuration options are described in 669.Xr ssh_config 5 . 670.Sh ENVIRONMENT 671.Nm 672will normally set the following environment variables: 673.Bl -tag -width Ds 674.It Ev DISPLAY 675The 676.Ev DISPLAY 677variable indicates the location of the X11 server. 678It is automatically set by 679.Nm 680to point to a value of the form 681.Dq hostname:n 682where hostname indicates 683the host where the shell runs, and n is an integer \*(>= 1. 684.Nm 685uses this special value to forward X11 connections over the secure 686channel. 687The user should normally not set 688.Ev DISPLAY 689explicitly, as that 690will render the X11 connection insecure (and will require the user to 691manually copy any required authorization cookies). 692.It Ev HOME 693Set to the path of the user's home directory. 694.It Ev LOGNAME 695Synonym for 696.Ev USER ; 697set for compatibility with systems that use this variable. 698.It Ev MAIL 699Set to the path of the user's mailbox. 700.It Ev PATH 701Set to the default 702.Ev PATH , 703as specified when compiling 704.Nm ssh . 705.It Ev SSH_ASKPASS 706If 707.Nm 708needs a passphrase, it will read the passphrase from the current 709terminal if it was run from a terminal. 710If 711.Nm 712does not have a terminal associated with it but 713.Ev DISPLAY 714and 715.Ev SSH_ASKPASS 716are set, it will execute the program specified by 717.Ev SSH_ASKPASS 718and open an X11 window to read the passphrase. 719This is particularly useful when calling 720.Nm 721from a 722.Pa .Xsession 723or related script. 724(Note that on some machines it 725may be necessary to redirect the input from 726.Pa /dev/null 727to make this work.) 728.It Ev SSH_AUTH_SOCK 729Identifies the path of a unix-domain socket used to communicate with the 730agent. 731.It Ev SSH_CONNECTION 732Identifies the client and server ends of the connection. 733The variable contains 734four space-separated values: client ip-address, client port number, 735server ip-address and server port number. 736.It Ev SSH_ORIGINAL_COMMAND 737The variable contains the original command line if a forced command 738is executed. 739It can be used to extract the original arguments. 740.It Ev SSH_TTY 741This is set to the name of the tty (path to the device) associated 742with the current shell or command. 743If the current session has no tty, 744this variable is not set. 745.It Ev TZ 746The timezone variable is set to indicate the present timezone if it 747was set when the daemon was started (i.e., the daemon passes the value 748on to new connections). 749.It Ev USER 750Set to the name of the user logging in. 751.El 752.Pp 753Additionally, 754.Nm 755reads 756.Pa $HOME/.ssh/environment , 757and adds lines of the format 758.Dq VARNAME=value 759to the environment if the file exists and if users are allowed to 760change their environment. 761See the 762.Cm PermitUserEnvironment 763option in 764.Xr sshd_config 5 . 765.Sh FILES 766.Bl -tag -width Ds 767.It Pa $HOME/.ssh/known_hosts 768Records host keys for all hosts the user has logged into that are not 769in 770.Pa /etc/ssh/ssh_known_hosts . 771See 772.Xr sshd 8 . 773.It Pa $HOME/.ssh/identity, $HOME/.ssh/id_dsa, $HOME/.ssh/id_rsa 774Contains the authentication identity of the user. 775They are for protocol 1 RSA, protocol 2 DSA, and protocol 2 RSA, respectively. 776These files 777contain sensitive data and should be readable by the user but not 778accessible by others (read/write/execute). 779Note that 780.Nm 781ignores a private key file if it is accessible by others. 782It is possible to specify a passphrase when 783generating the key; the passphrase will be used to encrypt the 784sensitive part of this file using 3DES. 785.It Pa $HOME/.ssh/identity.pub, $HOME/.ssh/id_dsa.pub, $HOME/.ssh/id_rsa.pub 786Contains the public key for authentication (public part of the 787identity file in human-readable form). 788The contents of the 789.Pa $HOME/.ssh/identity.pub 790file should be added to 791.Pa $HOME/.ssh/authorized_keys 792on all machines 793where the user wishes to log in using protocol version 1 RSA authentication. 794The contents of the 795.Pa $HOME/.ssh/id_dsa.pub 796and 797.Pa $HOME/.ssh/id_rsa.pub 798file should be added to 799.Pa $HOME/.ssh/authorized_keys 800on all machines 801where the user wishes to log in using protocol version 2 DSA/RSA authentication. 802These files are not 803sensitive and can (but need not) be readable by anyone. 804These files are 805never used automatically and are not necessary; they are only provided for 806the convenience of the user. 807.It Pa $HOME/.ssh/config 808This is the per-user configuration file. 809The file format and configuration options are described in 810.Xr ssh_config 5 . 811.It Pa $HOME/.ssh/authorized_keys 812Lists the public keys (RSA/DSA) that can be used for logging in as this user. 813The format of this file is described in the 814.Xr sshd 8 815manual page. 816In the simplest form the format is the same as the .pub 817identity files. 818This file is not highly sensitive, but the recommended 819permissions are read/write for the user, and not accessible by others. 820.It Pa /etc/ssh/ssh_known_hosts 821Systemwide list of known host keys. 822This file should be prepared by the 823system administrator to contain the public host keys of all machines in the 824organization. 825This file should be world-readable. 826This file contains 827public keys, one per line, in the following format (fields separated 828by spaces): system name, public key and optional comment field. 829When different names are used 830for the same machine, all such names should be listed, separated by 831commas. 832The format is described on the 833.Xr sshd 8 834manual page. 835.Pp 836The canonical system name (as returned by name servers) is used by 837.Xr sshd 8 838to verify the client host when logging in; other names are needed because 839.Nm 840does not convert the user-supplied name to a canonical name before 841checking the key, because someone with access to the name servers 842would then be able to fool host authentication. 843.It Pa /etc/ssh/ssh_config 844Systemwide configuration file. 845The file format and configuration options are described in 846.Xr ssh_config 5 . 847.It Pa /etc/ssh/ssh_host_key, /etc/ssh/ssh_host_dsa_key, /etc/ssh/ssh_host_rsa_key 848These three files contain the private parts of the host keys 849and are used for 850.Cm RhostsRSAAuthentication 851and 852.Cm HostbasedAuthentication . 853If the protocol version 1 854.Cm RhostsRSAAuthentication 855method is used, 856.Nm 857must be setuid root, since the host key is readable only by root. 858For protocol version 2, 859.Nm 860uses 861.Xr ssh-keysign 8 862to access the host keys for 863.Cm HostbasedAuthentication . 864This eliminates the requirement that 865.Nm 866be setuid root when that authentication method is used. 867By default 868.Nm 869is not setuid root. 870.It Pa $HOME/.rhosts 871This file is used in 872.Pa \&.rhosts 873authentication to list the 874host/user pairs that are permitted to log in. 875(Note that this file is 876also used by rlogin and rsh, which makes using this file insecure.) 877Each line of the file contains a host name (in the canonical form 878returned by name servers), and then a user name on that host, 879separated by a space. 880On some machines this file may need to be 881world-readable if the user's home directory is on a NFS partition, 882because 883.Xr sshd 8 884reads it as root. 885Additionally, this file must be owned by the user, 886and must not have write permissions for anyone else. 887The recommended 888permission for most machines is read/write for the user, and not 889accessible by others. 890.Pp 891Note that by default 892.Xr sshd 8 893will be installed so that it requires successful RSA host 894authentication before permitting \s+2.\s0rhosts authentication. 895If the server machine does not have the client's host key in 896.Pa /etc/ssh/ssh_known_hosts , 897it can be stored in 898.Pa $HOME/.ssh/known_hosts . 899The easiest way to do this is to 900connect back to the client from the server machine using ssh; this 901will automatically add the host key to 902.Pa $HOME/.ssh/known_hosts . 903.It Pa $HOME/.shosts 904This file is used exactly the same way as 905.Pa \&.rhosts . 906The purpose for 907having this file is to be able to use rhosts authentication with 908.Nm 909without permitting login with 910.Nm rlogin 911or 912.Xr rsh 1 . 913.It Pa /etc/hosts.equiv 914This file is used during 915.Pa \&.rhosts 916authentication. 917It contains 918canonical hosts names, one per line (the full format is described on 919the 920.Xr sshd 8 921manual page). 922If the client host is found in this file, login is 923automatically permitted provided client and server user names are the 924same. 925Additionally, successful RSA host authentication is normally 926required. 927This file should only be writable by root. 928.It Pa /etc/ssh/shosts.equiv 929This file is processed exactly as 930.Pa /etc/hosts.equiv . 931This file may be useful to permit logins using 932.Nm 933but not using rsh/rlogin. 934.It Pa /etc/ssh/sshrc 935Commands in this file are executed by 936.Nm 937when the user logs in just before the user's shell (or command) is started. 938See the 939.Xr sshd 8 940manual page for more information. 941.It Pa $HOME/.ssh/rc 942Commands in this file are executed by 943.Nm 944when the user logs in just before the user's shell (or command) is 945started. 946See the 947.Xr sshd 8 948manual page for more information. 949.It Pa $HOME/.ssh/environment 950Contains additional definitions for environment variables, see section 951.Sx ENVIRONMENT 952above. 953.El 954.Sh DIAGNOSTICS 955.Nm 956exits with the exit status of the remote command or with 255 957if an error occurred. 958.Sh AUTHORS 959OpenSSH is a derivative of the original and free 960ssh 1.2.12 release by Tatu Ylonen. 961Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 962Theo de Raadt and Dug Song 963removed many bugs, re-added newer features and 964created OpenSSH. 965Markus Friedl contributed the support for SSH 966protocol versions 1.5 and 2.0. 967.Sh SEE ALSO 968.Xr rsh 1 , 969.Xr scp 1 , 970.Xr sftp 1 , 971.Xr ssh-add 1 , 972.Xr ssh-agent 1 , 973.Xr ssh-keygen 1 , 974.Xr telnet 1 , 975.Xr ssh_config 5 , 976.Xr ssh-keysign 8 , 977.Xr sshd 8 978.Rs 979.%A T. Ylonen 980.%A T. Kivinen 981.%A M. Saarinen 982.%A T. Rinne 983.%A S. Lehtinen 984.%T "SSH Protocol Architecture" 985.%N draft-ietf-secsh-architecture-12.txt 986.%D January 2002 987.%O work in progress material 988.Re 989