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