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