]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - crypto/openssh/ssh.1
This commit was generated by cvs2svn to compensate for changes in r165538,
[FreeBSD/FreeBSD.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.265 2006/10/28 18:08:10 otto 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 1246AaCfgkMNnqsTtVvXxY
48 .Op Fl b Ar bind_address
49 .Op Fl c Ar cipher_spec
50 .Oo Fl D\ \&
51 .Sm off
52 .Oo Ar bind_address : Oc
53 .Ar port
54 .Sm on
55 .Oc
56 .Op Fl e Ar escape_char
57 .Op Fl F Ar configfile
58 .Bk -words
59 .Op Fl i Ar identity_file
60 .Ek
61 .Oo Fl L\ \&
62 .Sm off
63 .Oo Ar bind_address : Oc
64 .Ar port : host : hostport
65 .Sm on
66 .Oc
67 .Bk -words
68 .Op Fl l Ar login_name
69 .Ek
70 .Op Fl m Ar mac_spec
71 .Op Fl O Ar ctl_cmd
72 .Op Fl o Ar option
73 .Op Fl p Ar port
74 .Oo Fl R\ \&
75 .Sm off
76 .Oo Ar bind_address : Oc
77 .Ar port : host : hostport
78 .Sm on
79 .Oc
80 .Op Fl S Ar ctl_path
81 .Bk -words
82 .Oo Fl w Ar local_tun Ns
83 .Op : Ns Ar remote_tun Oc
84 .Oo Ar user Ns @ Oc Ns Ar hostname
85 .Op Ar command
86 .Ek
87 .Sh DESCRIPTION
88 .Nm
89 (SSH client) is a program for logging into a remote machine and for
90 executing commands on a remote machine.
91 It is intended to replace rlogin and rsh,
92 and provide secure encrypted communications between
93 two untrusted hosts over an insecure network.
94 X11 connections and arbitrary TCP ports
95 can also be forwarded over the secure channel.
96 .Pp
97 .Nm
98 connects and logs into the specified
99 .Ar hostname
100 (with optional
101 .Ar user
102 name).
103 The user must prove
104 his/her identity to the remote machine using one of several methods
105 depending on the protocol version used (see below).
106 .Pp
107 If
108 .Ar command
109 is specified,
110 it is executed on the remote host instead of a login shell.
111 .Pp
112 The options are as follows:
113 .Bl -tag -width Ds
114 .It Fl 1
115 Forces
116 .Nm
117 to try protocol version 1 only.
118 .It Fl 2
119 Forces
120 .Nm
121 to try protocol version 2 only.
122 .It Fl 4
123 Forces
124 .Nm
125 to use IPv4 addresses only.
126 .It Fl 6
127 Forces
128 .Nm
129 to use IPv6 addresses only.
130 .It Fl A
131 Enables forwarding of the authentication agent connection.
132 This can also be specified on a per-host basis in a configuration file.
133 .Pp
134 Agent forwarding should be enabled with caution.
135 Users with the ability to bypass file permissions on the remote host
136 (for the agent's Unix-domain socket)
137 can access the local agent through the forwarded connection.
138 An attacker cannot obtain key material from the agent,
139 however they can perform operations on the keys that enable them to
140 authenticate using the identities loaded into the agent.
141 .It Fl a
142 Disables forwarding of the authentication agent connection.
143 .It Fl b Ar bind_address
144 Use
145 .Ar bind_address
146 on the local machine as the source address
147 of the connection.
148 Only useful on systems with more than one address.
149 .It Fl C
150 Requests compression of all data (including stdin, stdout, stderr, and
151 data for forwarded X11 and TCP connections).
152 The compression algorithm is the same used by
153 .Xr gzip 1 ,
154 and the
155 .Dq level
156 can be controlled by the
157 .Cm CompressionLevel
158 option for protocol version 1.
159 Compression is desirable on modem lines and other
160 slow connections, but will only slow down things on fast networks.
161 The default value can be set on a host-by-host basis in the
162 configuration files; see the
163 .Cm Compression
164 option.
165 .It Fl c Ar cipher_spec
166 Selects the cipher specification for encrypting the session.
167 .Pp
168 Protocol version 1 allows specification of a single cipher.
169 The supported values are
170 .Dq 3des ,
171 .Dq blowfish ,
172 and
173 .Dq des .
174 .Ar 3des
175 (triple-des) is an encrypt-decrypt-encrypt triple with three different keys.
176 It is believed to be secure.
177 .Ar blowfish
178 is a fast block cipher; it appears very secure and is much faster than
179 .Ar 3des .
180 .Ar des
181 is only supported in the
182 .Nm
183 client for interoperability with legacy protocol 1 implementations
184 that do not support the
185 .Ar 3des
186 cipher.
187 Its use is strongly discouraged due to cryptographic weaknesses.
188 The default is
189 .Dq 3des .
190 .Pp
191 For protocol version 2,
192 .Ar cipher_spec
193 is a comma-separated list of ciphers
194 listed in order of preference.
195 The supported ciphers are:
196 3des-cbc,
197 aes128-cbc,
198 aes192-cbc,
199 aes256-cbc,
200 aes128-ctr,
201 aes192-ctr,
202 aes256-ctr,
203 arcfour128,
204 arcfour256,
205 arcfour,
206 blowfish-cbc,
207 and
208 cast128-cbc.
209 The default is:
210 .Bd -literal -offset indent
211 aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,
212 arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,
213 aes192-ctr,aes256-ctr
214 .Ed
215 .It Fl D Xo
216 .Sm off
217 .Oo Ar bind_address : Oc
218 .Ar port
219 .Sm on
220 .Xc
221 Specifies a local
222 .Dq dynamic
223 application-level port forwarding.
224 This works by allocating a socket to listen to
225 .Ar port
226 on the local side, optionally bound to the specified
227 .Ar bind_address .
228 Whenever a connection is made to this port, the
229 connection is forwarded over the secure channel, and the application
230 protocol is then used to determine where to connect to from the
231 remote machine.
232 Currently the SOCKS4 and SOCKS5 protocols are supported, and
233 .Nm
234 will act as a SOCKS server.
235 Only root can forward privileged ports.
236 Dynamic port forwardings can also be specified in the configuration file.
237 .Pp
238 IPv6 addresses can be specified with an alternative syntax:
239 .Sm off
240 .Xo
241 .Op Ar bind_address No /
242 .Ar port
243 .Xc
244 .Sm on
245 or by enclosing the address in square brackets.
246 Only the superuser can forward privileged ports.
247 By default, the local port is bound in accordance with the
248 .Cm GatewayPorts
249 setting.
250 However, an explicit
251 .Ar bind_address
252 may be used to bind the connection to a specific address.
253 The
254 .Ar bind_address
255 of
256 .Dq localhost
257 indicates that the listening port be bound for local use only, while an
258 empty address or
259 .Sq *
260 indicates that the port should be available from all interfaces.
261 .It Fl e Ar escape_char
262 Sets the escape character for sessions with a pty (default:
263 .Ql ~ ) .
264 The escape character is only recognized at the beginning of a line.
265 The escape character followed by a dot
266 .Pq Ql \&.
267 closes the connection;
268 followed by control-Z suspends the connection;
269 and followed by itself sends the escape character once.
270 Setting the character to
271 .Dq none
272 disables any escapes and makes the session fully transparent.
273 .It Fl F Ar configfile
274 Specifies an alternative per-user configuration file.
275 If a configuration file is given on the command line,
276 the system-wide configuration file
277 .Pq Pa /etc/ssh/ssh_config
278 will be ignored.
279 The default for the per-user configuration file is
280 .Pa ~/.ssh/config .
281 .It Fl f
282 Requests
283 .Nm
284 to go to background just before command execution.
285 This is useful if
286 .Nm
287 is going to ask for passwords or passphrases, but the user
288 wants it in the background.
289 This implies
290 .Fl n .
291 The recommended way to start X11 programs at a remote site is with
292 something like
293 .Ic ssh -f host xterm .
294 .It Fl g
295 Allows remote hosts to connect to local forwarded ports.
296 .It Fl I Ar smartcard_device
297 Specify the device
298 .Nm
299 should use to communicate with a smartcard used for storing the user's
300 private RSA key.
301 This option is only available if support for smartcard devices
302 is compiled in (default is no support).
303 .It Fl i Ar identity_file
304 Selects a file from which the identity (private key) for
305 RSA or DSA authentication is read.
306 The default is
307 .Pa ~/.ssh/identity
308 for protocol version 1, and
309 .Pa ~/.ssh/id_rsa
310 and
311 .Pa ~/.ssh/id_dsa
312 for protocol version 2.
313 Identity files may also be specified on
314 a per-host basis in the configuration file.
315 It is possible to have multiple
316 .Fl i
317 options (and multiple identities specified in
318 configuration files).
319 .It Fl k
320 Disables forwarding (delegation) of GSSAPI credentials to the server.
321 .It Fl L Xo
322 .Sm off
323 .Oo Ar bind_address : Oc
324 .Ar port : host : hostport
325 .Sm on
326 .Xc
327 Specifies that the given port on the local (client) host is to be
328 forwarded to the given host and port on the remote side.
329 This works by allocating a socket to listen to
330 .Ar port
331 on the local side, optionally bound to the specified
332 .Ar bind_address .
333 Whenever a connection is made to this port, the
334 connection is forwarded over the secure channel, and a connection is
335 made to
336 .Ar host
337 port
338 .Ar hostport
339 from the remote machine.
340 Port forwardings can also be specified in the configuration file.
341 IPv6 addresses can be specified with an alternative syntax:
342 .Sm off
343 .Xo
344 .Op Ar bind_address No /
345 .Ar port No / Ar host No /
346 .Ar hostport
347 .Xc
348 .Sm on
349 or by enclosing the address in square brackets.
350 Only the superuser can forward privileged ports.
351 By default, the local port is bound in accordance with the
352 .Cm GatewayPorts
353 setting.
354 However, an explicit
355 .Ar bind_address
356 may be used to bind the connection to a specific address.
357 The
358 .Ar bind_address
359 of
360 .Dq localhost
361 indicates that the listening port be bound for local use only, while an
362 empty address or
363 .Sq *
364 indicates that the port should be available from all interfaces.
365 .It Fl l Ar login_name
366 Specifies the user to log in as on the remote machine.
367 This also may be specified on a per-host basis in the configuration file.
368 .It Fl M
369 Places the
370 .Nm
371 client into
372 .Dq master
373 mode for connection sharing.
374 Multiple
375 .Fl M
376 options places
377 .Nm
378 into
379 .Dq master
380 mode with confirmation required before slave connections are accepted.
381 Refer to the description of
382 .Cm ControlMaster
383 in
384 .Xr ssh_config 5
385 for details.
386 .It Fl m Ar mac_spec
387 Additionally, for protocol version 2 a comma-separated list of MAC
388 (message authentication code) algorithms can
389 be specified in order of preference.
390 See the
391 .Cm MACs
392 keyword for more information.
393 .It Fl N
394 Do not execute a remote command.
395 This is useful for just forwarding ports
396 (protocol version 2 only).
397 .It Fl n
398 Redirects stdin from
399 .Pa /dev/null
400 (actually, prevents reading from stdin).
401 This must be used when
402 .Nm
403 is run in the background.
404 A common trick is to use this to run X11 programs on a remote machine.
405 For example,
406 .Ic ssh -n shadows.cs.hut.fi emacs &
407 will start an emacs on shadows.cs.hut.fi, and the X11
408 connection will be automatically forwarded over an encrypted channel.
409 The
410 .Nm
411 program will be put in the background.
412 (This does not work if
413 .Nm
414 needs to ask for a password or passphrase; see also the
415 .Fl f
416 option.)
417 .It Fl O Ar ctl_cmd
418 Control an active connection multiplexing master process.
419 When the
420 .Fl O
421 option is specified, the
422 .Ar ctl_cmd
423 argument is interpreted and passed to the master process.
424 Valid commands are:
425 .Dq check
426 (check that the master process is running) and
427 .Dq exit
428 (request the master to exit).
429 .It Fl o Ar option
430 Can be used to give options in the format used in the configuration file.
431 This is useful for specifying options for which there is no separate
432 command-line flag.
433 For full details of the options listed below, and their possible values, see
434 .Xr ssh_config 5 .
435 .Pp
436 .Bl -tag -width Ds -offset indent -compact
437 .It AddressFamily
438 .It BatchMode
439 .It BindAddress
440 .It ChallengeResponseAuthentication
441 .It CheckHostIP
442 .It Cipher
443 .It Ciphers
444 .It ClearAllForwardings
445 .It Compression
446 .It CompressionLevel
447 .It ConnectionAttempts
448 .It ConnectTimeout
449 .It ControlMaster
450 .It ControlPath
451 .It DynamicForward
452 .It EscapeChar
453 .It ExitOnForwardFailure
454 .It ForwardAgent
455 .It ForwardX11
456 .It ForwardX11Trusted
457 .It GatewayPorts
458 .It GlobalKnownHostsFile
459 .It GSSAPIAuthentication
460 .It GSSAPIDelegateCredentials
461 .It HashKnownHosts
462 .It Host
463 .It HostbasedAuthentication
464 .It HostKeyAlgorithms
465 .It HostKeyAlias
466 .It HostName
467 .It IdentityFile
468 .It IdentitiesOnly
469 .It KbdInteractiveDevices
470 .It LocalCommand
471 .It LocalForward
472 .It LogLevel
473 .It MACs
474 .It NoHostAuthenticationForLocalhost
475 .It NumberOfPasswordPrompts
476 .It PasswordAuthentication
477 .It PermitLocalCommand
478 .It Port
479 .It PreferredAuthentications
480 .It Protocol
481 .It ProxyCommand
482 .It PubkeyAuthentication
483 .It RekeyLimit
484 .It RemoteForward
485 .It RhostsRSAAuthentication
486 .It RSAAuthentication
487 .It SendEnv
488 .It ServerAliveInterval
489 .It ServerAliveCountMax
490 .It SmartcardDevice
491 .It StrictHostKeyChecking
492 .It TCPKeepAlive
493 .It Tunnel
494 .It TunnelDevice
495 .It UsePrivilegedPort
496 .It User
497 .It UserKnownHostsFile
498 .It VerifyHostKeyDNS
499 .It VersionAddendum
500 .It XAuthLocation
501 .El
502 .It Fl p Ar port
503 Port to connect to on the remote host.
504 This can be specified on a
505 per-host basis in the configuration file.
506 .It Fl q
507 Quiet mode.
508 Causes all warning and diagnostic messages to be suppressed.
509 .It Fl R Xo
510 .Sm off
511 .Oo Ar bind_address : Oc
512 .Ar port : host : hostport
513 .Sm on
514 .Xc
515 Specifies that the given port on the remote (server) host is to be
516 forwarded to the given host and port on the local side.
517 This works by allocating a socket to listen to
518 .Ar port
519 on the remote side, and whenever a connection is made to this port, the
520 connection is forwarded over the secure channel, and a connection is
521 made to
522 .Ar host
523 port
524 .Ar hostport
525 from the local machine.
526 .Pp
527 Port forwardings can also be specified in the configuration file.
528 Privileged ports can be forwarded only when
529 logging in as root on the remote machine.
530 IPv6 addresses can be specified by enclosing the address in square braces or
531 using an alternative syntax:
532 .Sm off
533 .Xo
534 .Op Ar bind_address No /
535 .Ar host No / Ar port No /
536 .Ar hostport
537 .Xc .
538 .Sm on
539 .Pp
540 By default, the listening socket on the server will be bound to the loopback
541 interface only.
542 This may be overriden by specifying a
543 .Ar bind_address .
544 An empty
545 .Ar bind_address ,
546 or the address
547 .Ql * ,
548 indicates that the remote socket should listen on all interfaces.
549 Specifying a remote
550 .Ar bind_address
551 will only succeed if the server's
552 .Cm GatewayPorts
553 option is enabled (see
554 .Xr sshd_config 5 ) .
555 .It Fl S Ar ctl_path
556 Specifies the location of a control socket for connection sharing.
557 Refer to the description of
558 .Cm ControlPath
559 and
560 .Cm ControlMaster
561 in
562 .Xr ssh_config 5
563 for details.
564 .It Fl s
565 May be used to request invocation of a subsystem on the remote system.
566 Subsystems are a feature of the SSH2 protocol which facilitate the use
567 of SSH as a secure transport for other applications (eg.\&
568 .Xr sftp 1 ) .
569 The subsystem is specified as the remote command.
570 .It Fl T
571 Disable pseudo-tty allocation.
572 .It Fl t
573 Force pseudo-tty allocation.
574 This can be used to execute arbitrary
575 screen-based programs on a remote machine, which can be very useful,
576 e.g. when implementing menu services.
577 Multiple
578 .Fl t
579 options force tty allocation, even if
580 .Nm
581 has no local tty.
582 .It Fl V
583 Display the version number and exit.
584 .It Fl v
585 Verbose mode.
586 Causes
587 .Nm
588 to print debugging messages about its progress.
589 This is helpful in
590 debugging connection, authentication, and configuration problems.
591 Multiple
592 .Fl v
593 options increase the verbosity.
594 The maximum is 3.
595 .It Fl w Xo
596 .Ar local_tun Ns Op : Ns Ar remote_tun
597 .Xc
598 Requests
599 tunnel
600 device forwarding with the specified
601 .Xr tun 4
602 devices between the client
603 .Pq Ar local_tun
604 and the server
605 .Pq Ar remote_tun .
606 .Pp
607 The devices may be specified by numerical ID or the keyword
608 .Dq any ,
609 which uses the next available tunnel device.
610 If
611 .Ar remote_tun
612 is not specified, it defaults to
613 .Dq any .
614 See also the
615 .Cm Tunnel
616 and
617 .Cm TunnelDevice
618 directives in
619 .Xr ssh_config 5 .
620 If the
621 .Cm Tunnel
622 directive is unset, it is set to the default tunnel mode, which is
623 .Dq point-to-point .
624 .It Fl X
625 Enables X11 forwarding.
626 This can also be specified on a per-host basis in a configuration file.
627 .Pp
628 X11 forwarding should be enabled with caution.
629 Users with the ability to bypass file permissions on the remote host
630 (for the user's X authorization database)
631 can access the local X11 display through the forwarded connection.
632 An attacker may then be able to perform activities such as keystroke monitoring.
633 .Pp
634 For this reason, X11 forwarding is subjected to X11 SECURITY extension
635 restrictions by default.
636 Please refer to the
637 .Nm
638 .Fl Y
639 option and the
640 .Cm ForwardX11Trusted
641 directive in
642 .Xr ssh_config 5
643 for more information.
644 .It Fl x
645 Disables X11 forwarding.
646 .It Fl Y
647 Enables trusted X11 forwarding.
648 Trusted X11 forwardings are not subjected to the X11 SECURITY extension
649 controls.
650 .El
651 .Pp
652 .Nm
653 may additionally obtain configuration data from
654 a per-user configuration file and a system-wide configuration file.
655 The file format and configuration options are described in
656 .Xr ssh_config 5 .
657 .Pp
658 .Nm
659 exits with the exit status of the remote command or with 255
660 if an error occurred.
661 .Sh AUTHENTICATION
662 The OpenSSH SSH client supports SSH protocols 1 and 2.
663 Protocol 2 is the default, with
664 .Nm
665 falling back to protocol 1 if it detects protocol 2 is unsupported.
666 These settings may be altered using the
667 .Cm Protocol
668 option in
669 .Xr ssh_config 5 ,
670 or enforced using the
671 .Fl 1
672 and
673 .Fl 2
674 options (see above).
675 Both protocols support similar authentication methods,
676 but protocol 2 is preferred since
677 it provides additional mechanisms for confidentiality
678 (the traffic is encrypted using AES, 3DES, Blowfish, CAST128, or Arcfour)
679 and integrity (hmac-md5, hmac-sha1, hmac-ripemd160).
680 Protocol 1 lacks a strong mechanism for ensuring the
681 integrity of the connection.
682 .Pp
683 The methods available for authentication are:
684 GSSAPI-based authentication,
685 host-based authentication,
686 public key authentication,
687 challenge-response authentication,
688 and password authentication.
689 Authentication methods are tried in the order specified above,
690 though protocol 2 has a configuration option to change the default order:
691 .Cm PreferredAuthentications .
692 .Pp
693 Host-based authentication works as follows:
694 If the machine the user logs in from is listed in
695 .Pa /etc/hosts.equiv
696 or
697 .Pa /etc/shosts.equiv
698 on the remote machine, and the user names are
699 the same on both sides, or if the files
700 .Pa ~/.rhosts
701 or
702 .Pa ~/.shosts
703 exist in the user's home directory on the
704 remote machine and contain a line containing the name of the client
705 machine and the name of the user on that machine, the user is
706 considered for login.
707 Additionally, the server
708 .Em must
709 be able to verify the client's
710 host key (see the description of
711 .Pa /etc/ssh/ssh_known_hosts
712 and
713 .Pa ~/.ssh/known_hosts ,
714 below)
715 for login to be permitted.
716 This authentication method closes security holes due to IP
717 spoofing, DNS spoofing, and routing spoofing.
718 [Note to the administrator:
719 .Pa /etc/hosts.equiv ,
720 .Pa ~/.rhosts ,
721 and the rlogin/rsh protocol in general, are inherently insecure and should be
722 disabled if security is desired.]
723 .Pp
724 Public key authentication works as follows:
725 The scheme is based on public-key cryptography,
726 using cryptosystems
727 where encryption and decryption are done using separate keys,
728 and it is unfeasible to derive the decryption key from the encryption key.
729 The idea is that each user creates a public/private
730 key pair for authentication purposes.
731 The server knows the public key, and only the user knows the private key.
732 .Nm
733 implements public key authentication protocol automatically,
734 using either the RSA or DSA algorithms.
735 Protocol 1 is restricted to using only RSA keys,
736 but protocol 2 may use either.
737 The
738 .Sx HISTORY
739 section of
740 .Xr ssl 8
741 contains a brief discussion of the two algorithms.
742 .Pp
743 The file
744 .Pa ~/.ssh/authorized_keys
745 lists the public keys that are permitted for logging in.
746 When the user logs in, the
747 .Nm
748 program tells the server which key pair it would like to use for
749 authentication.
750 The client proves that it has access to the private key
751 and the server checks that the corresponding public key
752 is authorized to accept the account.
753 .Pp
754 The user creates his/her key pair by running
755 .Xr ssh-keygen 1 .
756 This stores the private key in
757 .Pa ~/.ssh/identity
758 (protocol 1),
759 .Pa ~/.ssh/id_dsa
760 (protocol 2 DSA),
761 or
762 .Pa ~/.ssh/id_rsa
763 (protocol 2 RSA)
764 and stores the public key in
765 .Pa ~/.ssh/identity.pub
766 (protocol 1),
767 .Pa ~/.ssh/id_dsa.pub
768 (protocol 2 DSA),
769 or
770 .Pa ~/.ssh/id_rsa.pub
771 (protocol 2 RSA)
772 in the user's home directory.
773 The user should then copy the public key
774 to
775 .Pa ~/.ssh/authorized_keys
776 in his/her home directory on the remote machine.
777 The
778 .Pa authorized_keys
779 file corresponds to the conventional
780 .Pa ~/.rhosts
781 file, and has one key
782 per line, though the lines can be very long.
783 After this, the user can log in without giving the password.
784 .Pp
785 The most convenient way to use public key authentication may be with an
786 authentication agent.
787 See
788 .Xr ssh-agent 1
789 for more information.
790 .Pp
791 Challenge-response authentication works as follows:
792 The server sends an arbitrary
793 .Qq challenge
794 text, and prompts for a response.
795 Protocol 2 allows multiple challenges and responses;
796 protocol 1 is restricted to just one challenge/response.
797 Examples of challenge-response authentication include
798 BSD Authentication (see
799 .Xr login.conf 5 )
800 and PAM (some non-OpenBSD systems).
801 .Pp
802 Finally, if other authentication methods fail,
803 .Nm
804 prompts the user for a password.
805 The password is sent to the remote
806 host for checking; however, since all communications are encrypted,
807 the password cannot be seen by someone listening on the network.
808 .Pp
809 .Nm
810 automatically maintains and checks a database containing
811 identification for all hosts it has ever been used with.
812 Host keys are stored in
813 .Pa ~/.ssh/known_hosts
814 in the user's home directory.
815 Additionally, the file
816 .Pa /etc/ssh/ssh_known_hosts
817 is automatically checked for known hosts.
818 Any new hosts are automatically added to the user's file.
819 If a host's identification ever changes,
820 .Nm
821 warns about this and disables password authentication to prevent
822 server spoofing or man-in-the-middle attacks,
823 which could otherwise be used to circumvent the encryption.
824 The
825 .Cm StrictHostKeyChecking
826 option can be used to control logins to machines whose
827 host key is not known or has changed.
828 .Pp
829 When the user's identity has been accepted by the server, the server
830 either executes the given command, or logs into the machine and gives
831 the user a normal shell on the remote machine.
832 All communication with
833 the remote command or shell will be automatically encrypted.
834 .Pp
835 If a pseudo-terminal has been allocated (normal login session), the
836 user may use the escape characters noted below.
837 .Pp
838 If no pseudo-tty has been allocated,
839 the session is transparent and can be used to reliably transfer binary data.
840 On most systems, setting the escape character to
841 .Dq none
842 will also make the session transparent even if a tty is used.
843 .Pp
844 The session terminates when the command or shell on the remote
845 machine exits and all X11 and TCP connections have been closed.
846 .Sh ESCAPE CHARACTERS
847 When a pseudo-terminal has been requested,
848 .Nm
849 supports a number of functions through the use of an escape character.
850 .Pp
851 A single tilde character can be sent as
852 .Ic ~~
853 or by following the tilde by a character other than those described below.
854 The escape character must always follow a newline to be interpreted as
855 special.
856 The escape character can be changed in configuration files using the
857 .Cm EscapeChar
858 configuration directive or on the command line by the
859 .Fl e
860 option.
861 .Pp
862 The supported escapes (assuming the default
863 .Ql ~ )
864 are:
865 .Bl -tag -width Ds
866 .It Cm ~.
867 Disconnect.
868 .It Cm ~^Z
869 Background
870 .Nm .
871 .It Cm ~#
872 List forwarded connections.
873 .It Cm ~&
874 Background
875 .Nm
876 at logout when waiting for forwarded connection / X11 sessions to terminate.
877 .It Cm ~?
878 Display a list of escape characters.
879 .It Cm ~B
880 Send a BREAK to the remote system
881 (only useful for SSH protocol version 2 and if the peer supports it).
882 .It Cm ~C
883 Open command line.
884 Currently this allows the addition of port forwardings using the
885 .Fl L
886 and
887 .Fl R
888 options (see above).
889 It also allows the cancellation of existing remote port-forwardings
890 using
891 .Sm off
892 .Fl KR Oo Ar bind_address : Oc Ar port .
893 .Sm on
894 .Ic !\& Ns Ar command
895 allows the user to execute a local command if the
896 .Ic PermitLocalCommand
897 option is enabled in
898 .Xr ssh_config 5 .
899 Basic help is available, using the
900 .Fl h
901 option.
902 .It Cm ~R
903 Request rekeying of the connection
904 (only useful for SSH protocol version 2 and if the peer supports it).
905 .El
906 .Sh TCP FORWARDING
907 Forwarding of arbitrary TCP connections over the secure channel can
908 be specified either on the command line or in a configuration file.
909 One possible application of TCP forwarding is a secure connection to a
910 mail server; another is going through firewalls.
911 .Pp
912 In the example below, we look at encrypting communication between
913 an IRC client and server, even though the IRC server does not directly
914 support encrypted communications.
915 This works as follows:
916 the user connects to the remote host using
917 .Nm ,
918 specifying a port to be used to forward connections
919 to the remote server.
920 After that it is possible to start the service which is to be encrypted
921 on the client machine,
922 connecting to the same local port,
923 and
924 .Nm
925 will encrypt and forward the connection.
926 .Pp
927 The following example tunnels an IRC session from client machine
928 .Dq 127.0.0.1
929 (localhost)
930 to remote server
931 .Dq server.example.com :
932 .Bd -literal -offset 4n
933 $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10
934 $ irc -c '#users' -p 1234 pinky 127.0.0.1
935 .Ed
936 .Pp
937 This tunnels a connection to IRC server
938 .Dq server.example.com ,
939 joining channel
940 .Dq #users ,
941 nickname
942 .Dq pinky ,
943 using port 1234.
944 It doesn't matter which port is used,
945 as long as it's greater than 1023
946 (remember, only root can open sockets on privileged ports)
947 and doesn't conflict with any ports already in use.
948 The connection is forwarded to port 6667 on the remote server,
949 since that's the standard port for IRC services.
950 .Pp
951 The
952 .Fl f
953 option backgrounds
954 .Nm
955 and the remote command
956 .Dq sleep 10
957 is specified to allow an amount of time
958 (10 seconds, in the example)
959 to start the service which is to be tunnelled.
960 If no connections are made within the time specified,
961 .Nm
962 will exit.
963 .Sh X11 FORWARDING
964 If the
965 .Cm ForwardX11
966 variable is set to
967 .Dq yes
968 (or see the description of the
969 .Fl X ,
970 .Fl x ,
971 and
972 .Fl Y
973 options above)
974 and the user is using X11 (the
975 .Ev DISPLAY
976 environment variable is set), the connection to the X11 display is
977 automatically forwarded to the remote side in such a way that any X11
978 programs started from the shell (or command) will go through the
979 encrypted channel, and the connection to the real X server will be made
980 from the local machine.
981 The user should not manually set
982 .Ev DISPLAY .
983 Forwarding of X11 connections can be
984 configured on the command line or in configuration files.
985 .Pp
986 The
987 .Ev DISPLAY
988 value set by
989 .Nm
990 will point to the server machine, but with a display number greater than zero.
991 This is normal, and happens because
992 .Nm
993 creates a
994 .Dq proxy
995 X server on the server machine for forwarding the
996 connections over the encrypted channel.
997 .Pp
998 .Nm
999 will also automatically set up Xauthority data on the server machine.
1000 For this purpose, it will generate a random authorization cookie,
1001 store it in Xauthority on the server, and verify that any forwarded
1002 connections carry this cookie and replace it by the real cookie when
1003 the connection is opened.
1004 The real authentication cookie is never
1005 sent to the server machine (and no cookies are sent in the plain).
1006 .Pp
1007 If the
1008 .Cm ForwardAgent
1009 variable is set to
1010 .Dq yes
1011 (or see the description of the
1012 .Fl A
1013 and
1014 .Fl a
1015 options above) and
1016 the user is using an authentication agent, the connection to the agent
1017 is automatically forwarded to the remote side.
1018 .Sh VERIFYING HOST KEYS
1019 When connecting to a server for the first time,
1020 a fingerprint of the server's public key is presented to the user
1021 (unless the option
1022 .Cm StrictHostKeyChecking
1023 has been disabled).
1024 Fingerprints can be determined using
1025 .Xr ssh-keygen 1 :
1026 .Pp
1027 .Dl $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
1028 .Pp
1029 If the fingerprint is already known,
1030 it can be matched and verified,
1031 and the key can be accepted.
1032 If the fingerprint is unknown,
1033 an alternative method of verification is available:
1034 SSH fingerprints verified by DNS.
1035 An additional resource record (RR),
1036 SSHFP,
1037 is added to a zonefile
1038 and the connecting client is able to match the fingerprint
1039 with that of the key presented.
1040 .Pp
1041 In this example, we are connecting a client to a server,
1042 .Dq host.example.com .
1043 The SSHFP resource records should first be added to the zonefile for
1044 host.example.com:
1045 .Bd -literal -offset indent
1046 $ ssh-keygen -r host.example.com.
1047 .Ed
1048 .Pp
1049 The output lines will have to be added to the zonefile.
1050 To check that the zone is answering fingerprint queries:
1051 .Pp
1052 .Dl $ dig -t SSHFP host.example.com
1053 .Pp
1054 Finally the client connects:
1055 .Bd -literal -offset indent
1056 $ ssh -o "VerifyHostKeyDNS ask" host.example.com
1057 [...]
1058 Matching host key fingerprint found in DNS.
1059 Are you sure you want to continue connecting (yes/no)?
1060 .Ed
1061 .Pp
1062 See the
1063 .Cm VerifyHostKeyDNS
1064 option in
1065 .Xr ssh_config 5
1066 for more information.
1067 .Sh SSH-BASED VIRTUAL PRIVATE NETWORKS
1068 .Nm
1069 contains support for Virtual Private Network (VPN) tunnelling
1070 using the
1071 .Xr tun 4
1072 network pseudo-device,
1073 allowing two networks to be joined securely.
1074 The
1075 .Xr sshd_config 5
1076 configuration option
1077 .Cm PermitTunnel
1078 controls whether the server supports this,
1079 and at what level (layer 2 or 3 traffic).
1080 .Pp
1081 The following example would connect client network 10.0.50.0/24
1082 with remote network 10.0.99.0/24 using a point-to-point connection
1083 from 10.1.1.1 to 10.1.1.2,
1084 provided that the SSH server running on the gateway to the remote network,
1085 at 192.168.1.15, allows it.
1086 .Pp
1087 On the client:
1088 .Bd -literal -offset indent
1089 # ssh -f -w 0:1 192.168.1.15 true
1090 # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
1091 # route add 10.0.99.0/24 10.1.1.2
1092 .Ed
1093 .Pp
1094 On the server:
1095 .Bd -literal -offset indent
1096 # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
1097 # route add 10.0.50.0/24 10.1.1.1
1098 .Ed
1099 .Pp
1100 Client access may be more finely tuned via the
1101 .Pa /root/.ssh/authorized_keys
1102 file (see below) and the
1103 .Cm PermitRootLogin
1104 server option.
1105 The following entry would permit connections on
1106 .Xr tun 4
1107 device 1 from user
1108 .Dq jane
1109 and on tun device 2 from user
1110 .Dq john ,
1111 if
1112 .Cm PermitRootLogin
1113 is set to
1114 .Dq forced-commands-only :
1115 .Bd -literal -offset 2n
1116 tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
1117 tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
1118 .Ed
1119 .Pp
1120 Since an SSH-based setup entails a fair amount of overhead,
1121 it may be more suited to temporary setups,
1122 such as for wireless VPNs.
1123 More permanent VPNs are better provided by tools such as
1124 .Xr ipsecctl 8
1125 and
1126 .Xr isakmpd 8 .
1127 .Sh ENVIRONMENT
1128 .Nm
1129 will normally set the following environment variables:
1130 .Bl -tag -width "SSH_ORIGINAL_COMMAND"
1131 .It Ev DISPLAY
1132 The
1133 .Ev DISPLAY
1134 variable indicates the location of the X11 server.
1135 It is automatically set by
1136 .Nm
1137 to point to a value of the form
1138 .Dq hostname:n ,
1139 where
1140 .Dq hostname
1141 indicates the host where the shell runs, and
1142 .Sq n
1143 is an integer \*(Ge 1.
1144 .Nm
1145 uses this special value to forward X11 connections over the secure
1146 channel.
1147 The user should normally not set
1148 .Ev DISPLAY
1149 explicitly, as that
1150 will render the X11 connection insecure (and will require the user to
1151 manually copy any required authorization cookies).
1152 .It Ev HOME
1153 Set to the path of the user's home directory.
1154 .It Ev LOGNAME
1155 Synonym for
1156 .Ev USER ;
1157 set for compatibility with systems that use this variable.
1158 .It Ev MAIL
1159 Set to the path of the user's mailbox.
1160 .It Ev PATH
1161 Set to the default
1162 .Ev PATH ,
1163 as specified when compiling
1164 .Nm .
1165 .It Ev SSH_ASKPASS
1166 If
1167 .Nm
1168 needs a passphrase, it will read the passphrase from the current
1169 terminal if it was run from a terminal.
1170 If
1171 .Nm
1172 does not have a terminal associated with it but
1173 .Ev DISPLAY
1174 and
1175 .Ev SSH_ASKPASS
1176 are set, it will execute the program specified by
1177 .Ev SSH_ASKPASS
1178 and open an X11 window to read the passphrase.
1179 This is particularly useful when calling
1180 .Nm
1181 from a
1182 .Pa .xsession
1183 or related script.
1184 (Note that on some machines it
1185 may be necessary to redirect the input from
1186 .Pa /dev/null
1187 to make this work.)
1188 .It Ev SSH_AUTH_SOCK
1189 Identifies the path of a
1190 .Ux Ns -domain
1191 socket used to communicate with the agent.
1192 .It Ev SSH_CONNECTION
1193 Identifies the client and server ends of the connection.
1194 The variable contains
1195 four space-separated values: client IP address, client port number,
1196 server IP address, and server port number.
1197 .It Ev SSH_ORIGINAL_COMMAND
1198 This variable contains the original command line if a forced command
1199 is executed.
1200 It can be used to extract the original arguments.
1201 .It Ev SSH_TTY
1202 This is set to the name of the tty (path to the device) associated
1203 with the current shell or command.
1204 If the current session has no tty,
1205 this variable is not set.
1206 .It Ev TZ
1207 This variable is set to indicate the present time zone if it
1208 was set when the daemon was started (i.e. the daemon passes the value
1209 on to new connections).
1210 .It Ev USER
1211 Set to the name of the user logging in.
1212 .El
1213 .Pp
1214 Additionally,
1215 .Nm
1216 reads
1217 .Pa ~/.ssh/environment ,
1218 and adds lines of the format
1219 .Dq VARNAME=value
1220 to the environment if the file exists and users are allowed to
1221 change their environment.
1222 For more information, see the
1223 .Cm PermitUserEnvironment
1224 option in
1225 .Xr sshd_config 5 .
1226 .Sh FILES
1227 .Bl -tag -width Ds -compact
1228 .It ~/.rhosts
1229 This file is used for host-based authentication (see above).
1230 On some machines this file may need to be
1231 world-readable if the user's home directory is on an NFS partition,
1232 because
1233 .Xr sshd 8
1234 reads it as root.
1235 Additionally, this file must be owned by the user,
1236 and must not have write permissions for anyone else.
1237 The recommended
1238 permission for most machines is read/write for the user, and not
1239 accessible by others.
1240 .Pp
1241 .It ~/.shosts
1242 This file is used in exactly the same way as
1243 .Pa .rhosts ,
1244 but allows host-based authentication without permitting login with
1245 rlogin/rsh.
1246 .Pp
1247 .It ~/.ssh/authorized_keys
1248 Lists the public keys (RSA/DSA) that can be used for logging in as this user.
1249 The format of this file is described in the
1250 .Xr sshd 8
1251 manual page.
1252 This file is not highly sensitive, but the recommended
1253 permissions are read/write for the user, and not accessible by others.
1254 .Pp
1255 .It ~/.ssh/config
1256 This is the per-user configuration file.
1257 The file format and configuration options are described in
1258 .Xr ssh_config 5 .
1259 Because of the potential for abuse, this file must have strict permissions:
1260 read/write for the user, and not accessible by others.
1261 .Pp
1262 .It ~/.ssh/environment
1263 Contains additional definitions for environment variables; see
1264 .Sx ENVIRONMENT ,
1265 above.
1266 .Pp
1267 .It ~/.ssh/identity
1268 .It ~/.ssh/id_dsa
1269 .It ~/.ssh/id_rsa
1270 Contains the private key for authentication.
1271 These files
1272 contain sensitive data and should be readable by the user but not
1273 accessible by others (read/write/execute).
1274 .Nm
1275 will simply ignore a private key file if it is accessible by others.
1276 It is possible to specify a passphrase when
1277 generating the key which will be used to encrypt the
1278 sensitive part of this file using 3DES.
1279 .Pp
1280 .It ~/.ssh/identity.pub
1281 .It ~/.ssh/id_dsa.pub
1282 .It ~/.ssh/id_rsa.pub
1283 Contains the public key for authentication.
1284 These files are not
1285 sensitive and can (but need not) be readable by anyone.
1286 .Pp
1287 .It ~/.ssh/known_hosts
1288 Contains a list of host keys for all hosts the user has logged into
1289 that are not already in the systemwide list of known host keys.
1290 See
1291 .Xr sshd 8
1292 for further details of the format of this file.
1293 .Pp
1294 .It ~/.ssh/rc
1295 Commands in this file are executed by
1296 .Nm
1297 when the user logs in, just before the user's shell (or command) is
1298 started.
1299 See the
1300 .Xr sshd 8
1301 manual page for more information.
1302 .Pp
1303 .It /etc/hosts.equiv
1304 This file is for host-based authentication (see above).
1305 It should only be writable by root.
1306 .Pp
1307 .It /etc/shosts.equiv
1308 This file is used in exactly the same way as
1309 .Pa hosts.equiv ,
1310 but allows host-based authentication without permitting login with
1311 rlogin/rsh.
1312 .Pp
1313 .It Pa /etc/ssh/ssh_config
1314 Systemwide configuration file.
1315 The file format and configuration options are described in
1316 .Xr ssh_config 5 .
1317 .Pp
1318 .It /etc/ssh/ssh_host_key
1319 .It /etc/ssh/ssh_host_dsa_key
1320 .It /etc/ssh/ssh_host_rsa_key
1321 These three files contain the private parts of the host keys
1322 and are used for host-based authentication.
1323 If protocol version 1 is used,
1324 .Nm
1325 must be setuid root, since the host key is readable only by root.
1326 For protocol version 2,
1327 .Nm
1328 uses
1329 .Xr ssh-keysign 8
1330 to access the host keys,
1331 eliminating the requirement that
1332 .Nm
1333 be setuid root when host-based authentication is used.
1334 By default
1335 .Nm
1336 is not setuid root.
1337 .Pp
1338 .It /etc/ssh/ssh_known_hosts
1339 Systemwide list of known host keys.
1340 This file should be prepared by the
1341 system administrator to contain the public host keys of all machines in the
1342 organization.
1343 It should be world-readable.
1344 See
1345 .Xr sshd 8
1346 for further details of the format of this file.
1347 .Pp
1348 .It /etc/ssh/sshrc
1349 Commands in this file are executed by
1350 .Nm
1351 when the user logs in, just before the user's shell (or command) is started.
1352 See the
1353 .Xr sshd 8
1354 manual page for more information.
1355 .El
1356 .Sh SEE ALSO
1357 .Xr scp 1 ,
1358 .Xr sftp 1 ,
1359 .Xr ssh-add 1 ,
1360 .Xr ssh-agent 1 ,
1361 .Xr ssh-keygen 1 ,
1362 .Xr ssh-keyscan 1 ,
1363 .Xr tun 4 ,
1364 .Xr hosts.equiv 5 ,
1365 .Xr ssh_config 5 ,
1366 .Xr ssh-keysign 8 ,
1367 .Xr sshd 8
1368 .Rs
1369 .%R RFC 4250
1370 .%T "The Secure Shell (SSH) Protocol Assigned Numbers"
1371 .%D 2006
1372 .Re
1373 .Rs
1374 .%R RFC 4251
1375 .%T "The Secure Shell (SSH) Protocol Architecture"
1376 .%D 2006
1377 .Re
1378 .Rs
1379 .%R RFC 4252
1380 .%T "The Secure Shell (SSH) Authentication Protocol"
1381 .%D 2006
1382 .Re
1383 .Rs
1384 .%R RFC 4253
1385 .%T "The Secure Shell (SSH) Transport Layer Protocol"
1386 .%D 2006
1387 .Re
1388 .Rs
1389 .%R RFC 4254
1390 .%T "The Secure Shell (SSH) Connection Protocol"
1391 .%D 2006
1392 .Re
1393 .Rs
1394 .%R RFC 4255
1395 .%T "Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints"
1396 .%D 2006
1397 .Re
1398 .Rs
1399 .%R RFC 4256
1400 .%T "Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)"
1401 .%D 2006
1402 .Re
1403 .Rs
1404 .%R RFC 4335
1405 .%T "The Secure Shell (SSH) Session Channel Break Extension"
1406 .%D 2006
1407 .Re
1408 .Rs
1409 .%R RFC 4344
1410 .%T "The Secure Shell (SSH) Transport Layer Encryption Modes"
1411 .%D 2006
1412 .Re
1413 .Rs
1414 .%R RFC 4345
1415 .%T "Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol"
1416 .%D 2006
1417 .Re
1418 .Rs
1419 .%R RFC 4419
1420 .%T "Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol"
1421 .%D 2006
1422 .Re
1423 .Sh AUTHORS
1424 OpenSSH is a derivative of the original and free
1425 ssh 1.2.12 release by Tatu Ylonen.
1426 Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1427 Theo de Raadt and Dug Song
1428 removed many bugs, re-added newer features and
1429 created OpenSSH.
1430 Markus Friedl contributed the support for SSH
1431 protocol versions 1.5 and 2.0.