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