Annotation of src/usr.bin/ssh/ssh.1, Revision 1.379
1.1 deraadt 1: .\"
2: .\" Author: Tatu Ylonen <ylo@cs.hut.fi>
3: .\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4: .\" All rights reserved
5: .\"
1.59 deraadt 6: .\" As far as I am concerned, the code I have written for this software
7: .\" can be used freely for any purpose. Any derived versions of this
8: .\" software must be clearly marked as such, and if the derived work is
9: .\" incompatible with the protocol description in the RFC file, it must be
10: .\" called by a name other than "ssh" or "Secure Shell".
11: .\"
1.93 deraadt 12: .\" Copyright (c) 1999,2000 Markus Friedl. All rights reserved.
13: .\" Copyright (c) 1999 Aaron Campbell. All rights reserved.
14: .\" Copyright (c) 1999 Theo de Raadt. All rights reserved.
1.59 deraadt 15: .\"
16: .\" Redistribution and use in source and binary forms, with or without
17: .\" modification, are permitted provided that the following conditions
18: .\" are met:
19: .\" 1. Redistributions of source code must retain the above copyright
20: .\" notice, this list of conditions and the following disclaimer.
21: .\" 2. Redistributions in binary form must reproduce the above copyright
22: .\" notice, this list of conditions and the following disclaimer in the
23: .\" documentation and/or other materials provided with the distribution.
1.1 deraadt 24: .\"
1.59 deraadt 25: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 deraadt 35: .\"
1.379 ! jmc 36: .\" $OpenBSD: ssh.1,v 1.378 2017/05/02 13:44:51 jmc Exp $
! 37: .Dd $Mdocdate: May 2 2017 $
1.2 deraadt 38: .Dt SSH 1
39: .Os
40: .Sh NAME
41: .Nm ssh
1.96 deraadt 42: .Nd OpenSSH SSH client (remote login program)
1.2 deraadt 43: .Sh SYNOPSIS
44: .Nm ssh
1.306 jmc 45: .Bk -words
1.377 djm 46: .Op Fl 46AaCfGgKkMNnqsTtVvXxYy
1.108 markus 47: .Op Fl b Ar bind_address
1.51 markus 48: .Op Fl c Ar cipher_spec
1.306 jmc 49: .Op Fl D Oo Ar bind_address : Oc Ns Ar port
1.331 dtucker 50: .Op Fl E Ar log_file
1.2 deraadt 51: .Op Fl e Ar escape_char
1.176 jmc 52: .Op Fl F Ar configfile
1.292 jmc 53: .Op Fl I Ar pkcs11
1.2 deraadt 54: .Op Fl i Ar identity_file
1.376 jmc 55: .Op Fl J Oo Ar user Ns @ Oc Ns Ar host Ns Op : Ns Ar port
1.360 millert 56: .Op Fl L Ar address
1.176 jmc 57: .Op Fl l Ar login_name
58: .Op Fl m Ar mac_spec
1.198 djm 59: .Op Fl O Ar ctl_cmd
1.176 jmc 60: .Op Fl o Ar option
61: .Op Fl p Ar port
1.362 djm 62: .Op Fl Q Ar query_option
1.360 millert 63: .Op Fl R Ar address
1.198 djm 64: .Op Fl S Ar ctl_path
1.290 dtucker 65: .Op Fl W Ar host : Ns Ar port
1.306 jmc 66: .Op Fl w Ar local_tun Ns Op : Ns Ar remote_tun
1.176 jmc 67: .Oo Ar user Ns @ Oc Ns Ar hostname
1.2 deraadt 68: .Op Ar command
1.306 jmc 69: .Ek
1.44 aaron 70: .Sh DESCRIPTION
1.2 deraadt 71: .Nm
1.96 deraadt 72: (SSH client) is a program for logging into a remote machine and for
1.40 aaron 73: executing commands on a remote machine.
1.365 mmcc 74: It is intended to provide secure encrypted communications between
1.40 aaron 75: two untrusted hosts over an insecure network.
1.348 millert 76: X11 connections, arbitrary TCP ports and
77: .Ux Ns -domain
78: sockets can also be forwarded over the secure channel.
1.2 deraadt 79: .Pp
80: .Nm
1.44 aaron 81: connects and logs into the specified
1.176 jmc 82: .Ar hostname
83: (with optional
84: .Ar user
85: name).
1.1 deraadt 86: The user must prove
1.49 markus 87: his/her identity to the remote machine using one of several methods
1.365 mmcc 88: (see below).
1.49 markus 89: .Pp
1.176 jmc 90: If
91: .Ar command
92: is specified,
1.219 jmc 93: it is executed on the remote host instead of a login shell.
1.2 deraadt 94: .Pp
1.218 jmc 95: The options are as follows:
1.361 millert 96: .Pp
1.360 millert 97: .Bl -tag -width Ds -compact
1.218 jmc 98: .It Fl 4
99: Forces
1.2 deraadt 100: .Nm
1.218 jmc 101: to use IPv4 addresses only.
1.360 millert 102: .Pp
1.218 jmc 103: .It Fl 6
104: Forces
1.2 deraadt 105: .Nm
1.218 jmc 106: to use IPv6 addresses only.
1.360 millert 107: .Pp
1.218 jmc 108: .It Fl A
109: Enables forwarding of the authentication agent connection.
110: This can also be specified on a per-host basis in a configuration file.
1.2 deraadt 111: .Pp
1.218 jmc 112: Agent forwarding should be enabled with caution.
113: Users with the ability to bypass file permissions on the remote host
1.285 sobrado 114: (for the agent's
1.286 sobrado 115: .Ux Ns -domain
116: socket) can access the local agent through the forwarded connection.
1.218 jmc 117: An attacker cannot obtain key material from the agent,
118: however they can perform operations on the keys that enable them to
119: authenticate using the identities loaded into the agent.
1.360 millert 120: .Pp
1.218 jmc 121: .It Fl a
122: Disables forwarding of the authentication agent connection.
1.360 millert 123: .Pp
1.218 jmc 124: .It Fl b Ar bind_address
125: Use
126: .Ar bind_address
127: on the local machine as the source address
128: of the connection.
129: Only useful on systems with more than one address.
1.360 millert 130: .Pp
1.218 jmc 131: .It Fl C
132: Requests compression of all data (including stdin, stdout, stderr, and
1.348 millert 133: data for forwarded X11, TCP and
134: .Ux Ns -domain
135: connections).
1.218 jmc 136: The compression algorithm is the same used by
1.377 djm 137: .Xr gzip 1 .
1.218 jmc 138: Compression is desirable on modem lines and other
139: slow connections, but will only slow down things on fast networks.
140: The default value can be set on a host-by-host basis in the
141: configuration files; see the
142: .Cm Compression
143: option.
1.360 millert 144: .Pp
1.218 jmc 145: .It Fl c Ar cipher_spec
146: Selects the cipher specification for encrypting the session.
147: .Ar cipher_spec
148: is a comma-separated list of ciphers
149: listed in order of preference.
1.283 jmc 150: See the
151: .Cm Ciphers
1.307 dtucker 152: keyword in
153: .Xr ssh_config 5
154: for more information.
1.360 millert 155: .Pp
1.218 jmc 156: .It Fl D Xo
157: .Sm off
158: .Oo Ar bind_address : Oc
159: .Ar port
160: .Sm on
161: .Xc
162: Specifies a local
163: .Dq dynamic
164: application-level port forwarding.
165: This works by allocating a socket to listen to
166: .Ar port
167: on the local side, optionally bound to the specified
168: .Ar bind_address .
169: Whenever a connection is made to this port, the
170: connection is forwarded over the secure channel, and the application
171: protocol is then used to determine where to connect to from the
172: remote machine.
173: Currently the SOCKS4 and SOCKS5 protocols are supported, and
1.107 markus 174: .Nm
1.218 jmc 175: will act as a SOCKS server.
176: Only root can forward privileged ports.
177: Dynamic port forwardings can also be specified in the configuration file.
1.49 markus 178: .Pp
1.308 djm 179: IPv6 addresses can be specified by enclosing the address in square brackets.
1.218 jmc 180: Only the superuser can forward privileged ports.
181: By default, the local port is bound in accordance with the
182: .Cm GatewayPorts
183: setting.
184: However, an explicit
185: .Ar bind_address
186: may be used to bind the connection to a specific address.
187: The
188: .Ar bind_address
189: of
190: .Dq localhost
191: indicates that the listening port be bound for local use only, while an
192: empty address or
193: .Sq *
194: indicates that the port should be available from all interfaces.
1.360 millert 195: .Pp
1.331 dtucker 196: .It Fl E Ar log_file
197: Append debug logs to
198: .Ar log_file
199: instead of standard error.
1.360 millert 200: .Pp
1.229 jmc 201: .It Fl e Ar escape_char
1.218 jmc 202: Sets the escape character for sessions with a pty (default:
203: .Ql ~ ) .
204: The escape character is only recognized at the beginning of a line.
205: The escape character followed by a dot
206: .Pq Ql \&.
207: closes the connection;
208: followed by control-Z suspends the connection;
209: and followed by itself sends the escape character once.
210: Setting the character to
1.2 deraadt 211: .Dq none
1.218 jmc 212: disables any escapes and makes the session fully transparent.
1.360 millert 213: .Pp
1.218 jmc 214: .It Fl F Ar configfile
215: Specifies an alternative per-user configuration file.
216: If a configuration file is given on the command line,
217: the system-wide configuration file
218: .Pq Pa /etc/ssh/ssh_config
219: will be ignored.
220: The default for the per-user configuration file is
221: .Pa ~/.ssh/config .
1.360 millert 222: .Pp
1.218 jmc 223: .It Fl f
224: Requests
225: .Nm
226: to go to background just before command execution.
227: This is useful if
1.176 jmc 228: .Nm
1.218 jmc 229: is going to ask for passwords or passphrases, but the user
230: wants it in the background.
231: This implies
232: .Fl n .
233: The recommended way to start X11 programs at a remote site is with
234: something like
235: .Ic ssh -f host xterm .
1.277 djm 236: .Pp
237: If the
238: .Cm ExitOnForwardFailure
239: configuration option is set to
240: .Dq yes ,
241: then a client started with
242: .Fl f
243: will wait for all remote port forwards to be successfully established
244: before placing itself in the background.
1.360 millert 245: .Pp
1.350 djm 246: .It Fl G
247: Causes
248: .Nm
249: to print its configuration after evaluating
250: .Cm Host
251: and
252: .Cm Match
253: blocks and exit.
1.360 millert 254: .Pp
1.218 jmc 255: .It Fl g
256: Allows remote hosts to connect to local forwarded ports.
1.346 djm 257: If used on a multiplexed connection, then this option must be specified
258: on the master process.
1.360 millert 259: .Pp
1.291 markus 260: .It Fl I Ar pkcs11
1.294 jmc 261: Specify the PKCS#11 shared library
1.176 jmc 262: .Nm
1.293 markus 263: should use to communicate with a PKCS#11 token providing the user's
1.218 jmc 264: private RSA key.
1.360 millert 265: .Pp
1.218 jmc 266: .It Fl i Ar identity_file
267: Selects a file from which the identity (private key) for
1.310 djm 268: public key authentication is read.
1.218 jmc 269: The default is
1.310 djm 270: .Pa ~/.ssh/id_dsa ,
1.343 naddy 271: .Pa ~/.ssh/id_ecdsa ,
272: .Pa ~/.ssh/id_ed25519
1.310 djm 273: and
1.218 jmc 274: .Pa ~/.ssh/id_rsa
275: for protocol version 2.
276: Identity files may also be specified on
277: a per-host basis in the configuration file.
278: It is possible to have multiple
279: .Fl i
280: options (and multiple identities specified in
281: configuration files).
1.364 jmc 282: If no certificates have been explicitly specified by the
1.363 djm 283: .Cm CertificateFile
284: directive,
1.302 djm 285: .Nm
286: will also try to load certificate information from the filename obtained
287: by appending
288: .Pa -cert.pub
289: to identity filenames.
1.360 millert 290: .Pp
1.375 djm 291: .It Fl J Xo
292: .Sm off
1.376 jmc 293: .Op Ar user No @
294: .Ar host
295: .Op : Ar port
1.375 djm 296: .Sm on
297: .Xc
298: Connect to the target host by first making a
299: .Nm
1.376 jmc 300: connection to the jump
301: .Ar host
302: and then establishing a TCP forwarding to the ultimate destination from
1.375 djm 303: there.
304: Multiple jump hops may be specified separated by comma characters.
305: This is a shortcut to specify a
306: .Cm ProxyJump
307: configuration directive.
308: .Pp
1.269 djm 309: .It Fl K
310: Enables GSSAPI-based authentication and forwarding (delegation) of GSSAPI
311: credentials to the server.
1.360 millert 312: .Pp
1.218 jmc 313: .It Fl k
314: Disables forwarding (delegation) of GSSAPI credentials to the server.
1.360 millert 315: .Pp
1.218 jmc 316: .It Fl L Xo
317: .Sm off
318: .Oo Ar bind_address : Oc
319: .Ar port : host : hostport
320: .Sm on
321: .Xc
1.360 millert 322: .It Fl L Xo
323: .Sm off
324: .Oo Ar bind_address : Oc
325: .Ar port : remote_socket
326: .Sm on
327: .Xc
328: .It Fl L Xo
329: .Sm off
330: .Ar local_socket : host : hostport
331: .Sm on
332: .Xc
333: .It Fl L Xo
334: .Sm off
335: .Ar local_socket : remote_socket
336: .Sm on
337: .Xc
338: Specifies that connections to the given TCP port or Unix socket on the local
339: (client) host are to be forwarded to the given host and port, or Unix socket,
340: on the remote side.
341: This works by allocating a socket to listen to either a TCP
1.218 jmc 342: .Ar port
343: on the local side, optionally bound to the specified
1.360 millert 344: .Ar bind_address ,
345: or to a Unix socket.
346: Whenever a connection is made to the local port or socket, the
1.218 jmc 347: connection is forwarded over the secure channel, and a connection is
1.360 millert 348: made to either
1.218 jmc 349: .Ar host
350: port
1.360 millert 351: .Ar hostport ,
352: or the Unix socket
353: .Ar remote_socket ,
1.218 jmc 354: from the remote machine.
1.360 millert 355: .Pp
1.218 jmc 356: Port forwardings can also be specified in the configuration file.
1.360 millert 357: Only the superuser can forward privileged ports.
1.308 djm 358: IPv6 addresses can be specified by enclosing the address in square brackets.
1.360 millert 359: .Pp
1.218 jmc 360: By default, the local port is bound in accordance with the
361: .Cm GatewayPorts
362: setting.
363: However, an explicit
364: .Ar bind_address
365: may be used to bind the connection to a specific address.
1.2 deraadt 366: The
1.218 jmc 367: .Ar bind_address
368: of
369: .Dq localhost
370: indicates that the listening port be bound for local use only, while an
371: empty address or
372: .Sq *
373: indicates that the port should be available from all interfaces.
1.360 millert 374: .Pp
1.218 jmc 375: .It Fl l Ar login_name
376: Specifies the user to log in as on the remote machine.
377: This also may be specified on a per-host basis in the configuration file.
1.360 millert 378: .Pp
1.218 jmc 379: .It Fl M
380: Places the
381: .Nm
382: client into
383: .Dq master
384: mode for connection sharing.
1.231 stevesk 385: Multiple
386: .Fl M
387: options places
388: .Nm
389: into
390: .Dq master
391: mode with confirmation required before slave connections are accepted.
1.218 jmc 392: Refer to the description of
393: .Cm ControlMaster
394: in
395: .Xr ssh_config 5
396: for details.
1.360 millert 397: .Pp
1.218 jmc 398: .It Fl m Ar mac_spec
1.369 jmc 399: A comma-separated list of MAC (message authentication code) algorithms,
400: specified in order of preference.
1.218 jmc 401: See the
402: .Cm MACs
403: keyword for more information.
1.360 millert 404: .Pp
1.218 jmc 405: .It Fl N
406: Do not execute a remote command.
1.369 jmc 407: This is useful for just forwarding ports.
1.360 millert 408: .Pp
1.218 jmc 409: .It Fl n
410: Redirects stdin from
411: .Pa /dev/null
412: (actually, prevents reading from stdin).
413: This must be used when
1.2 deraadt 414: .Nm
1.218 jmc 415: is run in the background.
416: A common trick is to use this to run X11 programs on a remote machine.
417: For example,
418: .Ic ssh -n shadows.cs.hut.fi emacs &
419: will start an emacs on shadows.cs.hut.fi, and the X11
420: connection will be automatically forwarded over an encrypted channel.
421: The
1.2 deraadt 422: .Nm
1.218 jmc 423: program will be put in the background.
424: (This does not work if
1.2 deraadt 425: .Nm
1.218 jmc 426: needs to ask for a password or passphrase; see also the
427: .Fl f
428: option.)
1.360 millert 429: .Pp
1.218 jmc 430: .It Fl O Ar ctl_cmd
431: Control an active connection multiplexing master process.
432: When the
433: .Fl O
434: option is specified, the
435: .Ar ctl_cmd
436: argument is interpreted and passed to the master process.
437: Valid commands are:
438: .Dq check
1.305 markus 439: (check that the master process is running),
440: .Dq forward
1.318 jmc 441: (request forwardings without command execution),
1.323 okan 442: .Dq cancel
443: (cancel forwardings),
1.218 jmc 444: .Dq exit
1.318 jmc 445: (request the master to exit), and
1.317 djm 446: .Dq stop
447: (request the master to stop accepting further multiplexing requests).
1.360 millert 448: .Pp
1.218 jmc 449: .It Fl o Ar option
450: Can be used to give options in the format used in the configuration file.
451: This is useful for specifying options for which there is no separate
452: command-line flag.
453: For full details of the options listed below, and their possible values, see
454: .Xr ssh_config 5 .
1.2 deraadt 455: .Pp
1.218 jmc 456: .Bl -tag -width Ds -offset indent -compact
1.366 jcs 457: .It AddKeysToAgent
1.218 jmc 458: .It AddressFamily
459: .It BatchMode
460: .It BindAddress
1.338 djm 461: .It CanonicalDomains
1.339 djm 462: .It CanonicalizeFallbackLocal
463: .It CanonicalizeHostname
464: .It CanonicalizeMaxDots
465: .It CanonicalizePermittedCNAMEs
1.363 djm 466: .It CertificateFile
1.218 jmc 467: .It ChallengeResponseAuthentication
468: .It CheckHostIP
469: .It Ciphers
470: .It ClearAllForwardings
471: .It Compression
472: .It ConnectTimeout
473: .It ControlMaster
474: .It ControlPath
1.321 djm 475: .It ControlPersist
1.218 jmc 476: .It DynamicForward
477: .It EscapeChar
1.263 markus 478: .It ExitOnForwardFailure
1.353 jmc 479: .It FingerprintHash
1.218 jmc 480: .It ForwardAgent
481: .It ForwardX11
1.321 djm 482: .It ForwardX11Timeout
1.218 jmc 483: .It ForwardX11Trusted
484: .It GatewayPorts
485: .It GlobalKnownHostsFile
486: .It GSSAPIAuthentication
487: .It GSSAPIDelegateCredentials
488: .It HashKnownHosts
489: .It Host
490: .It HostbasedAuthentication
1.355 djm 491: .It HostbasedKeyTypes
1.218 jmc 492: .It HostKeyAlgorithms
493: .It HostKeyAlias
494: .It HostName
1.374 jmc 495: .It IdentitiesOnly
1.371 markus 496: .It IdentityAgent
1.218 jmc 497: .It IdentityFile
1.370 djm 498: .It Include
1.316 jmc 499: .It IPQoS
1.321 djm 500: .It KbdInteractiveAuthentication
1.218 jmc 501: .It KbdInteractiveDevices
1.314 jmc 502: .It KexAlgorithms
1.218 jmc 503: .It LocalCommand
504: .It LocalForward
505: .It LogLevel
506: .It MACs
1.337 jmc 507: .It Match
1.218 jmc 508: .It NoHostAuthenticationForLocalhost
509: .It NumberOfPasswordPrompts
510: .It PasswordAuthentication
511: .It PermitLocalCommand
1.291 markus 512: .It PKCS11Provider
1.218 jmc 513: .It Port
514: .It PreferredAuthentications
515: .It ProxyCommand
1.375 djm 516: .It ProxyJump
1.336 jmc 517: .It ProxyUseFdpass
1.359 markus 518: .It PubkeyAcceptedKeyTypes
1.218 jmc 519: .It PubkeyAuthentication
1.251 dtucker 520: .It RekeyLimit
1.218 jmc 521: .It RemoteForward
1.319 jmc 522: .It RequestTTY
1.218 jmc 523: .It SendEnv
524: .It ServerAliveInterval
525: .It ServerAliveCountMax
1.347 jmc 526: .It StreamLocalBindMask
527: .It StreamLocalBindUnlink
1.218 jmc 528: .It StrictHostKeyChecking
529: .It TCPKeepAlive
530: .It Tunnel
531: .It TunnelDevice
1.354 djm 532: .It UpdateHostKeys
1.218 jmc 533: .It UsePrivilegedPort
534: .It User
535: .It UserKnownHostsFile
536: .It VerifyHostKeyDNS
1.276 jmc 537: .It VisualHostKey
1.218 jmc 538: .It XAuthLocation
539: .El
1.360 millert 540: .Pp
1.218 jmc 541: .It Fl p Ar port
542: Port to connect to on the remote host.
543: This can be specified on a
544: per-host basis in the configuration file.
1.360 millert 545: .Pp
1.362 djm 546: .It Fl Q Ar query_option
1.332 djm 547: Queries
548: .Nm
1.341 deraadt 549: for the algorithms supported for the specified version 2.
550: The available features are:
551: .Ar cipher
1.332 djm 552: (supported symmetric ciphers),
1.341 deraadt 553: .Ar cipher-auth
1.340 djm 554: (supported symmetric ciphers that support authenticated encryption),
1.341 deraadt 555: .Ar mac
1.332 djm 556: (supported message integrity codes),
1.341 deraadt 557: .Ar kex
1.332 djm 558: (key exchange algorithms),
1.341 deraadt 559: .Ar key
1.362 djm 560: (key types),
561: .Ar key-cert
562: (certificate key types),
563: .Ar key-plain
564: (non-certificate key types), and
1.356 djm 565: .Ar protocol-version
566: (supported SSH protocol versions).
1.360 millert 567: .Pp
1.218 jmc 568: .It Fl q
569: Quiet mode.
1.271 djm 570: Causes most warning and diagnostic messages to be suppressed.
1.360 millert 571: .Pp
1.218 jmc 572: .It Fl R Xo
573: .Sm off
574: .Oo Ar bind_address : Oc
575: .Ar port : host : hostport
576: .Sm on
577: .Xc
1.360 millert 578: .It Fl R Xo
579: .Sm off
580: .Oo Ar bind_address : Oc
581: .Ar port : local_socket
582: .Sm on
583: .Xc
584: .It Fl R Xo
585: .Sm off
586: .Ar remote_socket : host : hostport
587: .Sm on
588: .Xc
589: .It Fl R Xo
590: .Sm off
591: .Ar remote_socket : local_socket
592: .Sm on
593: .Xc
594: Specifies that connections to the given TCP port or Unix socket on the remote
595: (server) host are to be forwarded to the given host and port, or Unix socket,
596: on the local side.
597: This works by allocating a socket to listen to either a TCP
1.218 jmc 598: .Ar port
1.360 millert 599: or to a Unix socket on the remote side.
600: Whenever a connection is made to this port or Unix socket, the
601: connection is forwarded over the secure channel, and a connection
602: is made to either
1.218 jmc 603: .Ar host
604: port
1.360 millert 605: .Ar hostport ,
606: or
607: .Ar local_socket ,
1.218 jmc 608: from the local machine.
1.2 deraadt 609: .Pp
1.218 jmc 610: Port forwardings can also be specified in the configuration file.
611: Privileged ports can be forwarded only when
612: logging in as root on the remote machine.
1.324 jmc 613: IPv6 addresses can be specified by enclosing the address in square brackets.
1.194 jakob 614: .Pp
1.360 millert 615: By default, TCP listening sockets on the server will be bound to the loopback
1.218 jmc 616: interface only.
1.280 tobias 617: This may be overridden by specifying a
1.218 jmc 618: .Ar bind_address .
619: An empty
620: .Ar bind_address ,
621: or the address
622: .Ql * ,
623: indicates that the remote socket should listen on all interfaces.
624: Specifying a remote
625: .Ar bind_address
626: will only succeed if the server's
627: .Cm GatewayPorts
628: option is enabled (see
629: .Xr sshd_config 5 ) .
1.281 djm 630: .Pp
631: If the
632: .Ar port
633: argument is
1.282 djm 634: .Ql 0 ,
1.281 djm 635: the listen port will be dynamically allocated on the server and reported
636: to the client at run time.
1.305 markus 637: When used together with
638: .Ic -O forward
639: the allocated port will be printed to the standard output.
1.360 millert 640: .Pp
1.218 jmc 641: .It Fl S Ar ctl_path
1.304 jmc 642: Specifies the location of a control socket for connection sharing,
1.303 djm 643: or the string
644: .Dq none
645: to disable connection sharing.
1.218 jmc 646: Refer to the description of
647: .Cm ControlPath
648: and
649: .Cm ControlMaster
650: in
651: .Xr ssh_config 5
652: for details.
1.360 millert 653: .Pp
1.218 jmc 654: .It Fl s
655: May be used to request invocation of a subsystem on the remote system.
1.369 jmc 656: Subsystems facilitate the use of SSH
657: as a secure transport for other applications (e.g.\&
1.218 jmc 658: .Xr sftp 1 ) .
659: The subsystem is specified as the remote command.
1.360 millert 660: .Pp
1.218 jmc 661: .It Fl T
1.357 dtucker 662: Disable pseudo-terminal allocation.
1.360 millert 663: .Pp
1.218 jmc 664: .It Fl t
1.357 dtucker 665: Force pseudo-terminal allocation.
1.218 jmc 666: This can be used to execute arbitrary
667: screen-based programs on a remote machine, which can be very useful,
1.257 jmc 668: e.g. when implementing menu services.
1.218 jmc 669: Multiple
670: .Fl t
671: options force tty allocation, even if
1.194 jakob 672: .Nm
1.218 jmc 673: has no local tty.
1.360 millert 674: .Pp
1.218 jmc 675: .It Fl V
676: Display the version number and exit.
1.360 millert 677: .Pp
1.218 jmc 678: .It Fl v
679: Verbose mode.
680: Causes
1.176 jmc 681: .Nm
1.218 jmc 682: to print debugging messages about its progress.
683: This is helpful in
684: debugging connection, authentication, and configuration problems.
685: Multiple
686: .Fl v
687: options increase the verbosity.
688: The maximum is 3.
1.360 millert 689: .Pp
1.290 dtucker 690: .It Fl W Ar host : Ns Ar port
691: Requests that standard input and output on the client be forwarded to
692: .Ar host
693: on
694: .Ar port
695: over the secure channel.
696: Implies
697: .Fl N ,
698: .Fl T ,
699: .Cm ExitOnForwardFailure
700: and
1.373 jmc 701: .Cm ClearAllForwardings ,
702: though these can be overridden in the configuration file or using
1.372 dtucker 703: .Fl o
704: command line options.
1.360 millert 705: .Pp
1.261 stevesk 706: .It Fl w Xo
707: .Ar local_tun Ns Op : Ns Ar remote_tun
708: .Xc
709: Requests
710: tunnel
711: device forwarding with the specified
1.218 jmc 712: .Xr tun 4
1.261 stevesk 713: devices between the client
714: .Pq Ar local_tun
715: and the server
716: .Pq Ar remote_tun .
717: .Pp
1.228 jmc 718: The devices may be specified by numerical ID or the keyword
719: .Dq any ,
720: which uses the next available tunnel device.
1.261 stevesk 721: If
722: .Ar remote_tun
723: is not specified, it defaults to
724: .Dq any .
1.228 jmc 725: See also the
1.218 jmc 726: .Cm Tunnel
1.261 stevesk 727: and
728: .Cm TunnelDevice
729: directives in
1.218 jmc 730: .Xr ssh_config 5 .
1.261 stevesk 731: If the
732: .Cm Tunnel
733: directive is unset, it is set to the default tunnel mode, which is
734: .Dq point-to-point .
1.360 millert 735: .Pp
1.218 jmc 736: .It Fl X
737: Enables X11 forwarding.
1.54 markus 738: This can also be specified on a per-host basis in a configuration file.
1.165 stevesk 739: .Pp
1.218 jmc 740: X11 forwarding should be enabled with caution.
1.168 jmc 741: Users with the ability to bypass file permissions on the remote host
1.218 jmc 742: (for the user's X authorization database)
743: can access the local X11 display through the forwarded connection.
744: An attacker may then be able to perform activities such as keystroke monitoring.
745: .Pp
746: For this reason, X11 forwarding is subjected to X11 SECURITY extension
747: restrictions by default.
748: Please refer to the
749: .Nm
750: .Fl Y
751: option and the
752: .Cm ForwardX11Trusted
753: directive in
754: .Xr ssh_config 5
755: for more information.
1.360 millert 756: .Pp
1.218 jmc 757: .It Fl x
758: Disables X11 forwarding.
1.360 millert 759: .Pp
1.218 jmc 760: .It Fl Y
761: Enables trusted X11 forwarding.
762: Trusted X11 forwardings are not subjected to the X11 SECURITY extension
763: controls.
1.360 millert 764: .Pp
1.278 djm 765: .It Fl y
766: Send log information using the
767: .Xr syslog 3
768: system module.
769: By default this information is sent to stderr.
1.218 jmc 770: .El
1.224 jmc 771: .Pp
772: .Nm
773: may additionally obtain configuration data from
774: a per-user configuration file and a system-wide configuration file.
775: The file format and configuration options are described in
776: .Xr ssh_config 5 .
1.222 jmc 777: .Sh AUTHENTICATION
1.377 djm 778: The OpenSSH SSH client supports SSH protocol 2.
1.222 jmc 779: .Pp
780: The methods available for authentication are:
1.260 jmc 781: GSSAPI-based authentication,
1.222 jmc 782: host-based authentication,
783: public key authentication,
784: challenge-response authentication,
785: and password authentication.
786: Authentication methods are tried in the order specified above,
1.369 jmc 787: though
788: .Cm PreferredAuthentications
789: can be used to change the default order.
1.222 jmc 790: .Pp
791: Host-based authentication works as follows:
1.218 jmc 792: If the machine the user logs in from is listed in
793: .Pa /etc/hosts.equiv
794: or
795: .Pa /etc/shosts.equiv
796: on the remote machine, and the user names are
797: the same on both sides, or if the files
798: .Pa ~/.rhosts
799: or
800: .Pa ~/.shosts
801: exist in the user's home directory on the
802: remote machine and contain a line containing the name of the client
803: machine and the name of the user on that machine, the user is
1.222 jmc 804: considered for login.
805: Additionally, the server
806: .Em must
807: be able to verify the client's
808: host key (see the description of
1.218 jmc 809: .Pa /etc/ssh/ssh_known_hosts
1.189 dtucker 810: and
1.222 jmc 811: .Pa ~/.ssh/known_hosts ,
812: below)
813: for login to be permitted.
1.218 jmc 814: This authentication method closes security holes due to IP
1.222 jmc 815: spoofing, DNS spoofing, and routing spoofing.
1.218 jmc 816: [Note to the administrator:
817: .Pa /etc/hosts.equiv ,
818: .Pa ~/.rhosts ,
819: and the rlogin/rsh protocol in general, are inherently insecure and should be
820: disabled if security is desired.]
1.189 dtucker 821: .Pp
1.222 jmc 822: Public key authentication works as follows:
823: The scheme is based on public-key cryptography,
824: using cryptosystems
825: where encryption and decryption are done using separate keys,
826: and it is unfeasible to derive the decryption key from the encryption key.
1.218 jmc 827: The idea is that each user creates a public/private
828: key pair for authentication purposes.
829: The server knows the public key, and only the user knows the private key.
1.222 jmc 830: .Nm
831: implements public key authentication protocol automatically,
1.349 sobrado 832: using one of the DSA, ECDSA, Ed25519 or RSA algorithms.
1.333 jmc 833: The HISTORY section of
1.222 jmc 834: .Xr ssl 8
1.311 jmc 835: contains a brief discussion of the DSA and RSA algorithms.
1.210 djm 836: .Pp
1.218 jmc 837: The file
838: .Pa ~/.ssh/authorized_keys
839: lists the public keys that are permitted for logging in.
840: When the user logs in, the
1.2 deraadt 841: .Nm
1.218 jmc 842: program tells the server which key pair it would like to use for
843: authentication.
1.222 jmc 844: The client proves that it has access to the private key
845: and the server checks that the corresponding public key
846: is authorized to accept the account.
1.218 jmc 847: .Pp
1.222 jmc 848: The user creates his/her key pair by running
1.218 jmc 849: .Xr ssh-keygen 1 .
850: This stores the private key in
1.222 jmc 851: .Pa ~/.ssh/id_dsa
1.369 jmc 852: (DSA),
1.310 djm 853: .Pa ~/.ssh/id_ecdsa
1.369 jmc 854: (ECDSA),
1.343 naddy 855: .Pa ~/.ssh/id_ed25519
1.369 jmc 856: (Ed25519),
1.222 jmc 857: or
858: .Pa ~/.ssh/id_rsa
1.369 jmc 859: (RSA)
1.218 jmc 860: and stores the public key in
1.222 jmc 861: .Pa ~/.ssh/id_dsa.pub
1.369 jmc 862: (DSA),
1.310 djm 863: .Pa ~/.ssh/id_ecdsa.pub
1.369 jmc 864: (ECDSA),
1.343 naddy 865: .Pa ~/.ssh/id_ed25519.pub
1.369 jmc 866: (Ed25519),
1.222 jmc 867: or
868: .Pa ~/.ssh/id_rsa.pub
1.369 jmc 869: (RSA)
1.218 jmc 870: in the user's home directory.
1.222 jmc 871: The user should then copy the public key
1.218 jmc 872: to
873: .Pa ~/.ssh/authorized_keys
1.222 jmc 874: in his/her home directory on the remote machine.
875: The
1.218 jmc 876: .Pa authorized_keys
877: file corresponds to the conventional
878: .Pa ~/.rhosts
879: file, and has one key
1.222 jmc 880: per line, though the lines can be very long.
1.218 jmc 881: After this, the user can log in without giving the password.
882: .Pp
1.301 jmc 883: A variation on public key authentication
884: is available in the form of certificate authentication:
885: instead of a set of public/private keys,
886: signed certificates are used.
887: This has the advantage that a single trusted certification authority
888: can be used in place of many public/private keys.
1.333 jmc 889: See the CERTIFICATES section of
1.301 jmc 890: .Xr ssh-keygen 1
891: for more information.
892: .Pp
893: The most convenient way to use public key or certificate authentication
894: may be with an authentication agent.
1.218 jmc 895: See
896: .Xr ssh-agent 1
1.366 jcs 897: and (optionally) the
898: .Cm AddKeysToAgent
899: directive in
900: .Xr ssh_config 5
1.218 jmc 901: for more information.
902: .Pp
1.222 jmc 903: Challenge-response authentication works as follows:
904: The server sends an arbitrary
905: .Qq challenge
906: text, and prompts for a response.
907: Examples of challenge-response authentication include
1.335 jmc 908: .Bx
909: Authentication (see
1.222 jmc 910: .Xr login.conf 5 )
1.335 jmc 911: and PAM (some
912: .Pf non- Ox
913: systems).
1.222 jmc 914: .Pp
915: Finally, if other authentication methods fail,
1.218 jmc 916: .Nm
917: prompts the user for a password.
918: The password is sent to the remote
919: host for checking; however, since all communications are encrypted,
920: the password cannot be seen by someone listening on the network.
1.232 jmc 921: .Pp
922: .Nm
923: automatically maintains and checks a database containing
924: identification for all hosts it has ever been used with.
925: Host keys are stored in
926: .Pa ~/.ssh/known_hosts
927: in the user's home directory.
928: Additionally, the file
929: .Pa /etc/ssh/ssh_known_hosts
930: is automatically checked for known hosts.
931: Any new hosts are automatically added to the user's file.
932: If a host's identification ever changes,
933: .Nm
934: warns about this and disables password authentication to prevent
935: server spoofing or man-in-the-middle attacks,
936: which could otherwise be used to circumvent the encryption.
937: The
938: .Cm StrictHostKeyChecking
939: option can be used to control logins to machines whose
940: host key is not known or has changed.
941: .Pp
1.218 jmc 942: When the user's identity has been accepted by the server, the server
1.357 dtucker 943: either executes the given command in a non-interactive session or,
944: if no command has been specified, logs into the machine and gives
945: the user a normal shell as an interactive session.
1.218 jmc 946: All communication with
947: the remote command or shell will be automatically encrypted.
948: .Pp
1.357 dtucker 949: If an interactive session is requested
950: .Nm
951: by default will only request a pseudo-terminal (pty) for interactive
952: sessions when the client has one.
953: The flags
954: .Fl T
955: and
956: .Fl t
957: can be used to override this behaviour.
958: .Pp
959: If a pseudo-terminal has been allocated the
1.218 jmc 960: user may use the escape characters noted below.
961: .Pp
1.357 dtucker 962: If no pseudo-terminal has been allocated,
1.218 jmc 963: the session is transparent and can be used to reliably transfer binary data.
964: On most systems, setting the escape character to
965: .Dq none
966: will also make the session transparent even if a tty is used.
967: .Pp
968: The session terminates when the command or shell on the remote
1.247 jmc 969: machine exits and all X11 and TCP connections have been closed.
1.223 jmc 970: .Sh ESCAPE CHARACTERS
1.218 jmc 971: When a pseudo-terminal has been requested,
1.2 deraadt 972: .Nm
1.218 jmc 973: supports a number of functions through the use of an escape character.
974: .Pp
975: A single tilde character can be sent as
976: .Ic ~~
977: or by following the tilde by a character other than those described below.
978: The escape character must always follow a newline to be interpreted as
979: special.
980: The escape character can be changed in configuration files using the
981: .Cm EscapeChar
982: configuration directive or on the command line by the
983: .Fl e
984: option.
985: .Pp
986: The supported escapes (assuming the default
987: .Ql ~ )
988: are:
989: .Bl -tag -width Ds
990: .It Cm ~.
991: Disconnect.
992: .It Cm ~^Z
993: Background
1.234 jmc 994: .Nm .
1.218 jmc 995: .It Cm ~#
996: List forwarded connections.
997: .It Cm ~&
998: Background
1.2 deraadt 999: .Nm
1.218 jmc 1000: at logout when waiting for forwarded connection / X11 sessions to terminate.
1001: .It Cm ~?
1002: Display a list of escape characters.
1003: .It Cm ~B
1004: Send a BREAK to the remote system
1.369 jmc 1005: (only useful if the peer supports it).
1.218 jmc 1006: .It Cm ~C
1007: Open command line.
1008: Currently this allows the addition of port forwardings using the
1.279 stevesk 1009: .Fl L ,
1010: .Fl R
1.218 jmc 1011: and
1.279 stevesk 1012: .Fl D
1.225 jmc 1013: options (see above).
1.322 markus 1014: It also allows the cancellation of existing port-forwardings
1015: with
1.262 stevesk 1016: .Sm off
1.322 markus 1017: .Fl KL Oo Ar bind_address : Oc Ar port
1.262 stevesk 1018: .Sm on
1.322 markus 1019: for local,
1020: .Sm off
1021: .Fl KR Oo Ar bind_address : Oc Ar port
1022: .Sm on
1023: for remote and
1024: .Sm off
1025: .Fl KD Oo Ar bind_address : Oc Ar port
1026: .Sm on
1027: for dynamic port-forwardings.
1.218 jmc 1028: .Ic !\& Ns Ar command
1029: allows the user to execute a local command if the
1030: .Ic PermitLocalCommand
1031: option is enabled in
1.176 jmc 1032: .Xr ssh_config 5 .
1.218 jmc 1033: Basic help is available, using the
1034: .Fl h
1035: option.
1036: .It Cm ~R
1037: Request rekeying of the connection
1.369 jmc 1038: (only useful if the peer supports it).
1.327 dtucker 1039: .It Cm ~V
1040: Decrease the verbosity
1041: .Pq Ic LogLevel
1042: when errors are being written to stderr.
1043: .It Cm ~v
1.328 jmc 1044: Increase the verbosity
1.327 dtucker 1045: .Pq Ic LogLevel
1046: when errors are being written to stderr.
1.176 jmc 1047: .El
1.246 jmc 1048: .Sh TCP FORWARDING
1049: Forwarding of arbitrary TCP connections over the secure channel can
1050: be specified either on the command line or in a configuration file.
1051: One possible application of TCP forwarding is a secure connection to a
1052: mail server; another is going through firewalls.
1053: .Pp
1054: In the example below, we look at encrypting communication between
1055: an IRC client and server, even though the IRC server does not directly
1056: support encrypted communications.
1057: This works as follows:
1058: the user connects to the remote host using
1059: .Nm ,
1060: specifying a port to be used to forward connections
1061: to the remote server.
1062: After that it is possible to start the service which is to be encrypted
1063: on the client machine,
1064: connecting to the same local port,
1065: and
1066: .Nm
1067: will encrypt and forward the connection.
1068: .Pp
1069: The following example tunnels an IRC session from client machine
1070: .Dq 127.0.0.1
1071: (localhost)
1072: to remote server
1073: .Dq server.example.com :
1074: .Bd -literal -offset 4n
1075: $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10
1076: $ irc -c '#users' -p 1234 pinky 127.0.0.1
1077: .Ed
1078: .Pp
1079: This tunnels a connection to IRC server
1080: .Dq server.example.com ,
1081: joining channel
1082: .Dq #users ,
1083: nickname
1084: .Dq pinky ,
1085: using port 1234.
1086: It doesn't matter which port is used,
1087: as long as it's greater than 1023
1088: (remember, only root can open sockets on privileged ports)
1089: and doesn't conflict with any ports already in use.
1090: The connection is forwarded to port 6667 on the remote server,
1091: since that's the standard port for IRC services.
1092: .Pp
1093: The
1094: .Fl f
1095: option backgrounds
1096: .Nm
1097: and the remote command
1098: .Dq sleep 10
1099: is specified to allow an amount of time
1100: (10 seconds, in the example)
1101: to start the service which is to be tunnelled.
1102: If no connections are made within the time specified,
1103: .Nm
1104: will exit.
1105: .Sh X11 FORWARDING
1.218 jmc 1106: If the
1107: .Cm ForwardX11
1108: variable is set to
1109: .Dq yes
1110: (or see the description of the
1.227 jmc 1111: .Fl X ,
1112: .Fl x ,
1.218 jmc 1113: and
1.227 jmc 1114: .Fl Y
1.226 jmc 1115: options above)
1.218 jmc 1116: and the user is using X11 (the
1117: .Ev DISPLAY
1118: environment variable is set), the connection to the X11 display is
1119: automatically forwarded to the remote side in such a way that any X11
1120: programs started from the shell (or command) will go through the
1121: encrypted channel, and the connection to the real X server will be made
1.176 jmc 1122: from the local machine.
1.218 jmc 1123: The user should not manually set
1124: .Ev DISPLAY .
1125: Forwarding of X11 connections can be
1126: configured on the command line or in configuration files.
1127: .Pp
1128: The
1129: .Ev DISPLAY
1130: value set by
1131: .Nm
1132: will point to the server machine, but with a display number greater than zero.
1133: This is normal, and happens because
1134: .Nm
1135: creates a
1136: .Dq proxy
1137: X server on the server machine for forwarding the
1138: connections over the encrypted channel.
1.200 djm 1139: .Pp
1.218 jmc 1140: .Nm
1141: will also automatically set up Xauthority data on the server machine.
1142: For this purpose, it will generate a random authorization cookie,
1143: store it in Xauthority on the server, and verify that any forwarded
1144: connections carry this cookie and replace it by the real cookie when
1145: the connection is opened.
1146: The real authentication cookie is never
1147: sent to the server machine (and no cookies are sent in the plain).
1.200 djm 1148: .Pp
1.218 jmc 1149: If the
1150: .Cm ForwardAgent
1151: variable is set to
1152: .Dq yes
1153: (or see the description of the
1154: .Fl A
1.191 djm 1155: and
1.218 jmc 1156: .Fl a
1.226 jmc 1157: options above) and
1.218 jmc 1158: the user is using an authentication agent, the connection to the agent
1159: is automatically forwarded to the remote side.
1.252 jmc 1160: .Sh VERIFYING HOST KEYS
1161: When connecting to a server for the first time,
1162: a fingerprint of the server's public key is presented to the user
1163: (unless the option
1164: .Cm StrictHostKeyChecking
1165: has been disabled).
1166: Fingerprints can be determined using
1167: .Xr ssh-keygen 1 :
1168: .Pp
1169: .Dl $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
1170: .Pp
1.274 grunk 1171: If the fingerprint is already known, it can be matched
1172: and the key can be accepted or rejected.
1.358 djm 1173: If only legacy (MD5) fingerprints for the server are available, the
1174: .Xr ssh-keygen 1
1175: .Fl E
1176: option may be used to downgrade the fingerprint algorithm to match.
1177: .Pp
1.274 grunk 1178: Because of the difficulty of comparing host keys
1.352 djm 1179: just by looking at fingerprint strings,
1.274 grunk 1180: there is also support to compare host keys visually,
1181: using
1182: .Em random art .
1183: By setting the
1.275 grunk 1184: .Cm VisualHostKey
1.274 grunk 1185: option to
1.275 grunk 1186: .Dq yes ,
1.274 grunk 1187: a small ASCII graphic gets displayed on every login to a server, no matter
1188: if the session itself is interactive or not.
1189: By learning the pattern a known server produces, a user can easily
1190: find out that the host key has changed when a completely different pattern
1191: is displayed.
1192: Because these patterns are not unambiguous however, a pattern that looks
1193: similar to the pattern remembered only gives a good probability that the
1194: host key is the same, not guaranteed proof.
1195: .Pp
1196: To get a listing of the fingerprints along with their random art for
1197: all known hosts, the following command line can be used:
1198: .Pp
1199: .Dl $ ssh-keygen -lv -f ~/.ssh/known_hosts
1200: .Pp
1.252 jmc 1201: If the fingerprint is unknown,
1202: an alternative method of verification is available:
1203: SSH fingerprints verified by DNS.
1204: An additional resource record (RR),
1205: SSHFP,
1206: is added to a zonefile
1207: and the connecting client is able to match the fingerprint
1208: with that of the key presented.
1209: .Pp
1210: In this example, we are connecting a client to a server,
1211: .Dq host.example.com .
1212: The SSHFP resource records should first be added to the zonefile for
1213: host.example.com:
1214: .Bd -literal -offset indent
1.259 jakob 1215: $ ssh-keygen -r host.example.com.
1.252 jmc 1216: .Ed
1217: .Pp
1218: The output lines will have to be added to the zonefile.
1219: To check that the zone is answering fingerprint queries:
1220: .Pp
1221: .Dl $ dig -t SSHFP host.example.com
1222: .Pp
1223: Finally the client connects:
1224: .Bd -literal -offset indent
1225: $ ssh -o "VerifyHostKeyDNS ask" host.example.com
1226: [...]
1227: Matching host key fingerprint found in DNS.
1228: Are you sure you want to continue connecting (yes/no)?
1229: .Ed
1230: .Pp
1231: See the
1232: .Cm VerifyHostKeyDNS
1233: option in
1234: .Xr ssh_config 5
1235: for more information.
1.250 jmc 1236: .Sh SSH-BASED VIRTUAL PRIVATE NETWORKS
1237: .Nm
1238: contains support for Virtual Private Network (VPN) tunnelling
1239: using the
1240: .Xr tun 4
1241: network pseudo-device,
1242: allowing two networks to be joined securely.
1243: The
1244: .Xr sshd_config 5
1245: configuration option
1246: .Cm PermitTunnel
1247: controls whether the server supports this,
1248: and at what level (layer 2 or 3 traffic).
1249: .Pp
1250: The following example would connect client network 10.0.50.0/24
1.265 otto 1251: with remote network 10.0.99.0/24 using a point-to-point connection
1252: from 10.1.1.1 to 10.1.1.2,
1253: provided that the SSH server running on the gateway to the remote network,
1254: at 192.168.1.15, allows it.
1255: .Pp
1256: On the client:
1.250 jmc 1257: .Bd -literal -offset indent
1258: # ssh -f -w 0:1 192.168.1.15 true
1.265 otto 1259: # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
1260: # route add 10.0.99.0/24 10.1.1.2
1261: .Ed
1262: .Pp
1263: On the server:
1264: .Bd -literal -offset indent
1265: # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
1266: # route add 10.0.50.0/24 10.1.1.1
1.250 jmc 1267: .Ed
1268: .Pp
1269: Client access may be more finely tuned via the
1270: .Pa /root/.ssh/authorized_keys
1271: file (see below) and the
1272: .Cm PermitRootLogin
1273: server option.
1.255 jmc 1274: The following entry would permit connections on
1.250 jmc 1275: .Xr tun 4
1.255 jmc 1276: device 1 from user
1.250 jmc 1277: .Dq jane
1.255 jmc 1278: and on tun device 2 from user
1.250 jmc 1279: .Dq john ,
1280: if
1281: .Cm PermitRootLogin
1282: is set to
1283: .Dq forced-commands-only :
1284: .Bd -literal -offset 2n
1285: tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
1.254 msf 1286: tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
1.250 jmc 1287: .Ed
1288: .Pp
1.264 ray 1289: Since an SSH-based setup entails a fair amount of overhead,
1.250 jmc 1290: it may be more suited to temporary setups,
1291: such as for wireless VPNs.
1292: More permanent VPNs are better provided by tools such as
1293: .Xr ipsecctl 8
1294: and
1295: .Xr isakmpd 8 .
1.2 deraadt 1296: .Sh ENVIRONMENT
1297: .Nm
1.1 deraadt 1298: will normally set the following environment variables:
1.237 jmc 1299: .Bl -tag -width "SSH_ORIGINAL_COMMAND"
1.2 deraadt 1300: .It Ev DISPLAY
1301: The
1302: .Ev DISPLAY
1.40 aaron 1303: variable indicates the location of the X11 server.
1.44 aaron 1304: It is automatically set by
1.2 deraadt 1305: .Nm
1306: to point to a value of the form
1.233 jmc 1307: .Dq hostname:n ,
1308: where
1309: .Dq hostname
1310: indicates the host where the shell runs, and
1311: .Sq n
1312: is an integer \*(Ge 1.
1.40 aaron 1313: .Nm
1314: uses this special value to forward X11 connections over the secure
1315: channel.
1.107 markus 1316: The user should normally not set
1317: .Ev DISPLAY
1318: explicitly, as that
1.1 deraadt 1319: will render the X11 connection insecure (and will require the user to
1320: manually copy any required authorization cookies).
1.2 deraadt 1321: .It Ev HOME
1.1 deraadt 1322: Set to the path of the user's home directory.
1.2 deraadt 1323: .It Ev LOGNAME
1324: Synonym for
1.12 aaron 1325: .Ev USER ;
1326: set for compatibility with systems that use this variable.
1.2 deraadt 1327: .It Ev MAIL
1.129 stevesk 1328: Set to the path of the user's mailbox.
1.40 aaron 1329: .It Ev PATH
1.2 deraadt 1330: Set to the default
1331: .Ev PATH ,
1332: as specified when compiling
1.234 jmc 1333: .Nm .
1.118 markus 1334: .It Ev SSH_ASKPASS
1335: If
1336: .Nm
1337: needs a passphrase, it will read the passphrase from the current
1338: terminal if it was run from a terminal.
1339: If
1340: .Nm
1341: does not have a terminal associated with it but
1342: .Ev DISPLAY
1343: and
1344: .Ev SSH_ASKPASS
1345: are set, it will execute the program specified by
1346: .Ev SSH_ASKPASS
1347: and open an X11 window to read the passphrase.
1348: This is particularly useful when calling
1349: .Nm
1350: from a
1.196 jmc 1351: .Pa .xsession
1.118 markus 1352: or related script.
1353: (Note that on some machines it
1354: may be necessary to redirect the input from
1355: .Pa /dev/null
1356: to make this work.)
1.18 markus 1357: .It Ev SSH_AUTH_SOCK
1.233 jmc 1358: Identifies the path of a
1359: .Ux Ns -domain
1360: socket used to communicate with the agent.
1.166 stevesk 1361: .It Ev SSH_CONNECTION
1362: Identifies the client and server ends of the connection.
1.40 aaron 1363: The variable contains
1.233 jmc 1364: four space-separated values: client IP address, client port number,
1365: server IP address, and server port number.
1.73 markus 1366: .It Ev SSH_ORIGINAL_COMMAND
1.233 jmc 1367: This variable contains the original command line if a forced command
1.73 markus 1368: is executed.
1369: It can be used to extract the original arguments.
1.2 deraadt 1370: .It Ev SSH_TTY
1.1 deraadt 1371: This is set to the name of the tty (path to the device) associated
1.40 aaron 1372: with the current shell or command.
1373: If the current session has no tty,
1.1 deraadt 1374: this variable is not set.
1.2 deraadt 1375: .It Ev TZ
1.214 jmc 1376: This variable is set to indicate the present time zone if it
1.257 jmc 1377: was set when the daemon was started (i.e. the daemon passes the value
1.1 deraadt 1378: on to new connections).
1.2 deraadt 1379: .It Ev USER
1.1 deraadt 1380: Set to the name of the user logging in.
1.2 deraadt 1381: .El
1382: .Pp
1.44 aaron 1383: Additionally,
1.2 deraadt 1384: .Nm
1.44 aaron 1385: reads
1.207 djm 1386: .Pa ~/.ssh/environment ,
1.2 deraadt 1387: and adds lines of the format
1388: .Dq VARNAME=value
1.233 jmc 1389: to the environment if the file exists and users are allowed to
1.161 marc 1390: change their environment.
1.176 jmc 1391: For more information, see the
1.161 marc 1392: .Cm PermitUserEnvironment
1.162 stevesk 1393: option in
1.161 marc 1394: .Xr sshd_config 5 .
1.2 deraadt 1395: .Sh FILES
1.236 jmc 1396: .Bl -tag -width Ds -compact
1.309 jmc 1397: .It Pa ~/.rhosts
1.240 jmc 1398: This file is used for host-based authentication (see above).
1.92 markus 1399: On some machines this file may need to be
1.240 jmc 1400: world-readable if the user's home directory is on an NFS partition,
1.1 deraadt 1401: because
1.2 deraadt 1402: .Xr sshd 8
1.40 aaron 1403: reads it as root.
1404: Additionally, this file must be owned by the user,
1405: and must not have write permissions for anyone else.
1406: The recommended
1.1 deraadt 1407: permission for most machines is read/write for the user, and not
1408: accessible by others.
1.2 deraadt 1409: .Pp
1.309 jmc 1410: .It Pa ~/.shosts
1.240 jmc 1411: This file is used in exactly the same way as
1412: .Pa .rhosts ,
1413: but allows host-based authentication without permitting login with
1414: rlogin/rsh.
1.272 mcbride 1415: .Pp
1.309 jmc 1416: .It Pa ~/.ssh/
1.272 mcbride 1417: This directory is the default location for all user-specific configuration
1418: and authentication information.
1419: There is no general requirement to keep the entire contents of this directory
1420: secret, but the recommended permissions are read/write/execute for the user,
1421: and not accessible by others.
1.236 jmc 1422: .Pp
1.309 jmc 1423: .It Pa ~/.ssh/authorized_keys
1.349 sobrado 1424: Lists the public keys (DSA, ECDSA, Ed25519, RSA)
1.343 naddy 1425: that can be used for logging in as this user.
1.238 jmc 1426: The format of this file is described in the
1427: .Xr sshd 8
1428: manual page.
1429: This file is not highly sensitive, but the recommended
1430: permissions are read/write for the user, and not accessible by others.
1431: .Pp
1.309 jmc 1432: .It Pa ~/.ssh/config
1.238 jmc 1433: This is the per-user configuration file.
1434: The file format and configuration options are described in
1435: .Xr ssh_config 5 .
1436: Because of the potential for abuse, this file must have strict permissions:
1.334 djm 1437: read/write for the user, and not writable by others.
1.238 jmc 1438: .Pp
1.309 jmc 1439: .It Pa ~/.ssh/environment
1.239 jmc 1440: Contains additional definitions for environment variables; see
1441: .Sx ENVIRONMENT ,
1.238 jmc 1442: above.
1443: .Pp
1.309 jmc 1444: .It Pa ~/.ssh/id_dsa
1.310 djm 1445: .It Pa ~/.ssh/id_ecdsa
1.343 naddy 1446: .It Pa ~/.ssh/id_ed25519
1.309 jmc 1447: .It Pa ~/.ssh/id_rsa
1.238 jmc 1448: Contains the private key for authentication.
1449: These files
1450: contain sensitive data and should be readable by the user but not
1451: accessible by others (read/write/execute).
1452: .Nm
1453: will simply ignore a private key file if it is accessible by others.
1454: It is possible to specify a passphrase when
1455: generating the key which will be used to encrypt the
1456: sensitive part of this file using 3DES.
1457: .Pp
1.309 jmc 1458: .It Pa ~/.ssh/id_dsa.pub
1.310 djm 1459: .It Pa ~/.ssh/id_ecdsa.pub
1.343 naddy 1460: .It Pa ~/.ssh/id_ed25519.pub
1.309 jmc 1461: .It Pa ~/.ssh/id_rsa.pub
1.238 jmc 1462: Contains the public key for authentication.
1463: These files are not
1464: sensitive and can (but need not) be readable by anyone.
1465: .Pp
1.309 jmc 1466: .It Pa ~/.ssh/known_hosts
1.244 jmc 1467: Contains a list of host keys for all hosts the user has logged into
1468: that are not already in the systemwide list of known host keys.
1.238 jmc 1469: See
1.244 jmc 1470: .Xr sshd 8
1471: for further details of the format of this file.
1.238 jmc 1472: .Pp
1.309 jmc 1473: .It Pa ~/.ssh/rc
1.238 jmc 1474: Commands in this file are executed by
1475: .Nm
1.245 jmc 1476: when the user logs in, just before the user's shell (or command) is
1.238 jmc 1477: started.
1478: See the
1479: .Xr sshd 8
1480: manual page for more information.
1481: .Pp
1.309 jmc 1482: .It Pa /etc/hosts.equiv
1.240 jmc 1483: This file is for host-based authentication (see above).
1484: It should only be writable by root.
1.236 jmc 1485: .Pp
1.309 jmc 1486: .It Pa /etc/shosts.equiv
1.240 jmc 1487: This file is used in exactly the same way as
1488: .Pa hosts.equiv ,
1489: but allows host-based authentication without permitting login with
1490: rlogin/rsh.
1.236 jmc 1491: .Pp
1.238 jmc 1492: .It Pa /etc/ssh/ssh_config
1493: Systemwide configuration file.
1494: The file format and configuration options are described in
1495: .Xr ssh_config 5 .
1496: .Pp
1.309 jmc 1497: .It Pa /etc/ssh/ssh_host_key
1498: .It Pa /etc/ssh/ssh_host_dsa_key
1.310 djm 1499: .It Pa /etc/ssh/ssh_host_ecdsa_key
1.343 naddy 1500: .It Pa /etc/ssh/ssh_host_ed25519_key
1.309 jmc 1501: .It Pa /etc/ssh/ssh_host_rsa_key
1.325 dtucker 1502: These files contain the private parts of the host keys
1.245 jmc 1503: and are used for host-based authentication.
1.238 jmc 1504: .Pp
1.309 jmc 1505: .It Pa /etc/ssh/ssh_known_hosts
1.238 jmc 1506: Systemwide list of known host keys.
1507: This file should be prepared by the
1508: system administrator to contain the public host keys of all machines in the
1509: organization.
1.244 jmc 1510: It should be world-readable.
1511: See
1.238 jmc 1512: .Xr sshd 8
1.244 jmc 1513: for further details of the format of this file.
1.236 jmc 1514: .Pp
1.309 jmc 1515: .It Pa /etc/ssh/sshrc
1.1 deraadt 1516: Commands in this file are executed by
1.2 deraadt 1517: .Nm
1.245 jmc 1518: when the user logs in, just before the user's shell (or command) is started.
1.44 aaron 1519: See the
1.2 deraadt 1520: .Xr sshd 8
1.1 deraadt 1521: manual page for more information.
1.58 itojun 1522: .El
1.312 jmc 1523: .Sh EXIT STATUS
1524: .Nm
1525: exits with the exit status of the remote command or with 255
1526: if an error occurred.
1.2 deraadt 1527: .Sh SEE ALSO
1528: .Xr scp 1 ,
1.83 djm 1529: .Xr sftp 1 ,
1.2 deraadt 1530: .Xr ssh-add 1 ,
1531: .Xr ssh-agent 1 ,
1532: .Xr ssh-keygen 1 ,
1.242 jmc 1533: .Xr ssh-keyscan 1 ,
1.250 jmc 1534: .Xr tun 4 ,
1.159 stevesk 1535: .Xr ssh_config 5 ,
1.160 naddy 1536: .Xr ssh-keysign 8 ,
1.87 itojun 1537: .Xr sshd 8
1.329 jmc 1538: .Sh STANDARDS
1.106 markus 1539: .Rs
1.329 jmc 1540: .%A S. Lehtinen
1541: .%A C. Lonvick
1542: .%D January 2006
1.256 jmc 1543: .%R RFC 4250
1.329 jmc 1544: .%T The Secure Shell (SSH) Protocol Assigned Numbers
1.256 jmc 1545: .Re
1.329 jmc 1546: .Pp
1.256 jmc 1547: .Rs
1.329 jmc 1548: .%A T. Ylonen
1549: .%A C. Lonvick
1550: .%D January 2006
1.256 jmc 1551: .%R RFC 4251
1.329 jmc 1552: .%T The Secure Shell (SSH) Protocol Architecture
1.256 jmc 1553: .Re
1.329 jmc 1554: .Pp
1.256 jmc 1555: .Rs
1.329 jmc 1556: .%A T. Ylonen
1557: .%A C. Lonvick
1558: .%D January 2006
1.256 jmc 1559: .%R RFC 4252
1.329 jmc 1560: .%T The Secure Shell (SSH) Authentication Protocol
1.256 jmc 1561: .Re
1.329 jmc 1562: .Pp
1.256 jmc 1563: .Rs
1.329 jmc 1564: .%A T. Ylonen
1565: .%A C. Lonvick
1566: .%D January 2006
1.256 jmc 1567: .%R RFC 4253
1.329 jmc 1568: .%T The Secure Shell (SSH) Transport Layer Protocol
1.256 jmc 1569: .Re
1.329 jmc 1570: .Pp
1.256 jmc 1571: .Rs
1.329 jmc 1572: .%A T. Ylonen
1573: .%A C. Lonvick
1574: .%D January 2006
1.256 jmc 1575: .%R RFC 4254
1.329 jmc 1576: .%T The Secure Shell (SSH) Connection Protocol
1.256 jmc 1577: .Re
1.329 jmc 1578: .Pp
1.256 jmc 1579: .Rs
1.329 jmc 1580: .%A J. Schlyter
1581: .%A W. Griffin
1582: .%D January 2006
1.256 jmc 1583: .%R RFC 4255
1.329 jmc 1584: .%T Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
1.256 jmc 1585: .Re
1.329 jmc 1586: .Pp
1.256 jmc 1587: .Rs
1.329 jmc 1588: .%A F. Cusack
1589: .%A M. Forssen
1590: .%D January 2006
1.256 jmc 1591: .%R RFC 4256
1.329 jmc 1592: .%T Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
1.256 jmc 1593: .Re
1.329 jmc 1594: .Pp
1.256 jmc 1595: .Rs
1.329 jmc 1596: .%A J. Galbraith
1597: .%A P. Remaker
1598: .%D January 2006
1.256 jmc 1599: .%R RFC 4335
1.329 jmc 1600: .%T The Secure Shell (SSH) Session Channel Break Extension
1.256 jmc 1601: .Re
1.329 jmc 1602: .Pp
1.256 jmc 1603: .Rs
1.329 jmc 1604: .%A M. Bellare
1605: .%A T. Kohno
1606: .%A C. Namprempre
1607: .%D January 2006
1.256 jmc 1608: .%R RFC 4344
1.329 jmc 1609: .%T The Secure Shell (SSH) Transport Layer Encryption Modes
1.256 jmc 1610: .Re
1.329 jmc 1611: .Pp
1.256 jmc 1612: .Rs
1.329 jmc 1613: .%A B. Harris
1614: .%D January 2006
1.256 jmc 1615: .%R RFC 4345
1.329 jmc 1616: .%T Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol
1.258 djm 1617: .Re
1.329 jmc 1618: .Pp
1.258 djm 1619: .Rs
1.329 jmc 1620: .%A M. Friedl
1621: .%A N. Provos
1622: .%A W. Simpson
1623: .%D March 2006
1.258 djm 1624: .%R RFC 4419
1.329 jmc 1625: .%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
1.266 markus 1626: .Re
1.329 jmc 1627: .Pp
1.266 markus 1628: .Rs
1.329 jmc 1629: .%A J. Galbraith
1630: .%A R. Thayer
1631: .%D November 2006
1.266 markus 1632: .%R RFC 4716
1.329 jmc 1633: .%T The Secure Shell (SSH) Public Key File Format
1.313 djm 1634: .Re
1.329 jmc 1635: .Pp
1.313 djm 1636: .Rs
1.329 jmc 1637: .%A D. Stebila
1638: .%A J. Green
1639: .%D December 2009
1.313 djm 1640: .%R RFC 5656
1.329 jmc 1641: .%T Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
1.274 grunk 1642: .Re
1.329 jmc 1643: .Pp
1.274 grunk 1644: .Rs
1645: .%A A. Perrig
1646: .%A D. Song
1647: .%D 1999
1.329 jmc 1648: .%O International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99)
1649: .%T Hash Visualization: a New Technique to improve Real-World Security
1.106 markus 1650: .Re
1.173 jmc 1651: .Sh AUTHORS
1652: OpenSSH is a derivative of the original and free
1653: ssh 1.2.12 release by Tatu Ylonen.
1654: Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
1655: Theo de Raadt and Dug Song
1656: removed many bugs, re-added newer features and
1657: created OpenSSH.
1658: Markus Friedl contributed the support for SSH
1659: protocol versions 1.5 and 2.0.