]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - ssh.0
Vendor import of OpenSSH 7.7p1.
[FreeBSD/FreeBSD.git] / ssh.0
1 SSH(1)                      General Commands Manual                     SSH(1)
2
3 NAME
4      ssh M-bM-^@M-^S OpenSSH SSH client (remote login program)
5
6 SYNOPSIS
7      ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
8          [-c cipher_spec] [-D [bind_address:]port] [-E log_file]
9          [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
10          [-J destination] [-L address] [-l login_name] [-m mac_spec]
11          [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
12          [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination
13          [command]
14
15 DESCRIPTION
16      ssh (SSH client) is a program for logging into a remote machine and for
17      executing commands on a remote machine.  It is intended to provide secure
18      encrypted communications between two untrusted hosts over an insecure
19      network.  X11 connections, arbitrary TCP ports and UNIX-domain sockets
20      can also be forwarded over the secure channel.
21
22      ssh connects and logs into the specified destination, which may be
23      specified as either [user@]hostname or a URI of the form
24      ssh://[user@]hostname[:port].  The user must prove his/her identity to
25      the remote machine using one of several methods (see below).
26
27      If a command is specified, it is executed on the remote host instead of a
28      login shell.
29
30      The options are as follows:
31
32      -4      Forces ssh to use IPv4 addresses only.
33
34      -6      Forces ssh to use IPv6 addresses only.
35
36      -A      Enables forwarding of the authentication agent connection.  This
37              can also be specified on a per-host basis in a configuration
38              file.
39
40              Agent forwarding should be enabled with caution.  Users with the
41              ability to bypass file permissions on the remote host (for the
42              agent's UNIX-domain socket) can access the local agent through
43              the forwarded connection.  An attacker cannot obtain key material
44              from the agent, however they can perform operations on the keys
45              that enable them to authenticate using the identities loaded into
46              the agent.
47
48      -a      Disables forwarding of the authentication agent connection.
49
50      -B bind_interface
51              Bind to the address of bind_interface before attempting to
52              connect to the destination host.  This is only useful on systems
53              with more than one address.
54
55      -b bind_address
56              Use bind_address on the local machine as the source address of
57              the connection.  Only useful on systems with more than one
58              address.
59
60      -C      Requests compression of all data (including stdin, stdout,
61              stderr, and data for forwarded X11, TCP and UNIX-domain
62              connections).  The compression algorithm is the same used by
63              gzip(1).  Compression is desirable on modem lines and other slow
64              connections, but will only slow down things on fast networks.
65              The default value can be set on a host-by-host basis in the
66              configuration files; see the Compression option.
67
68      -c cipher_spec
69              Selects the cipher specification for encrypting the session.
70              cipher_spec is a comma-separated list of ciphers listed in order
71              of preference.  See the Ciphers keyword in ssh_config(5) for more
72              information.
73
74      -D [bind_address:]port
75              Specifies a local M-bM-^@M-^\dynamicM-bM-^@M-^] application-level port forwarding.
76              This works by allocating a socket to listen to port on the local
77              side, optionally bound to the specified bind_address.  Whenever a
78              connection is made to this port, the connection is forwarded over
79              the secure channel, and the application protocol is then used to
80              determine where to connect to from the remote machine.  Currently
81              the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
82              as a SOCKS server.  Only root can forward privileged ports.
83              Dynamic port forwardings can also be specified in the
84              configuration file.
85
86              IPv6 addresses can be specified by enclosing the address in
87              square brackets.  Only the superuser can forward privileged
88              ports.  By default, the local port is bound in accordance with
89              the GatewayPorts setting.  However, an explicit bind_address may
90              be used to bind the connection to a specific address.  The
91              bind_address of M-bM-^@M-^\localhostM-bM-^@M-^] indicates that the listening port be
92              bound for local use only, while an empty address or M-bM-^@M-^X*M-bM-^@M-^Y indicates
93              that the port should be available from all interfaces.
94
95      -E log_file
96              Append debug logs to log_file instead of standard error.
97
98      -e escape_char
99              Sets the escape character for sessions with a pty (default: M-bM-^@M-^X~M-bM-^@M-^Y).
100              The escape character is only recognized at the beginning of a
101              line.  The escape character followed by a dot (M-bM-^@M-^X.M-bM-^@M-^Y) closes the
102              connection; followed by control-Z suspends the connection; and
103              followed by itself sends the escape character once.  Setting the
104              character to M-bM-^@M-^\noneM-bM-^@M-^] disables any escapes and makes the session
105              fully transparent.
106
107      -F configfile
108              Specifies an alternative per-user configuration file.  If a
109              configuration file is given on the command line, the system-wide
110              configuration file (/etc/ssh/ssh_config) will be ignored.  The
111              default for the per-user configuration file is ~/.ssh/config.
112
113      -f      Requests ssh to go to background just before command execution.
114              This is useful if ssh is going to ask for passwords or
115              passphrases, but the user wants it in the background.  This
116              implies -n.  The recommended way to start X11 programs at a
117              remote site is with something like ssh -f host xterm.
118
119              If the ExitOnForwardFailure configuration option is set to M-bM-^@M-^\yesM-bM-^@M-^],
120              then a client started with -f will wait for all remote port
121              forwards to be successfully established before placing itself in
122              the background.
123
124      -G      Causes ssh to print its configuration after evaluating Host and
125              Match blocks and exit.
126
127      -g      Allows remote hosts to connect to local forwarded ports.  If used
128              on a multiplexed connection, then this option must be specified
129              on the master process.
130
131      -I pkcs11
132              Specify the PKCS#11 shared library ssh should use to communicate
133              with a PKCS#11 token providing the user's private RSA key.
134
135      -i identity_file
136              Selects a file from which the identity (private key) for public
137              key authentication is read.  The default is ~/.ssh/id_dsa,
138              ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/id_rsa.  Identity
139              files may also be specified on a per-host basis in the
140              configuration file.  It is possible to have multiple -i options
141              (and multiple identities specified in configuration files).  If
142              no certificates have been explicitly specified by the
143              CertificateFile directive, ssh will also try to load certificate
144              information from the filename obtained by appending -cert.pub to
145              identity filenames.
146
147      -J destination
148              Connect to the target host by first making a ssh connection to
149              the jump host described by destination and then establishing a
150              TCP forwarding to the ultimate destination from there.  Multiple
151              jump hops may be specified separated by comma characters.  This
152              is a shortcut to specify a ProxyJump configuration directive.
153
154      -K      Enables GSSAPI-based authentication and forwarding (delegation)
155              of GSSAPI credentials to the server.
156
157      -k      Disables forwarding (delegation) of GSSAPI credentials to the
158              server.
159
160      -L [bind_address:]port:host:hostport
161      -L [bind_address:]port:remote_socket
162      -L local_socket:host:hostport
163      -L local_socket:remote_socket
164              Specifies that connections to the given TCP port or Unix socket
165              on the local (client) host are to be forwarded to the given host
166              and port, or Unix socket, on the remote side.  This works by
167              allocating a socket to listen to either a TCP port on the local
168              side, optionally bound to the specified bind_address, or to a
169              Unix socket.  Whenever a connection is made to the local port or
170              socket, the connection is forwarded over the secure channel, and
171              a connection is made to either host port hostport, or the Unix
172              socket remote_socket, from the remote machine.
173
174              Port forwardings can also be specified in the configuration file.
175              Only the superuser can forward privileged ports.  IPv6 addresses
176              can be specified by enclosing the address in square brackets.
177
178              By default, the local port is bound in accordance with the
179              GatewayPorts setting.  However, an explicit bind_address may be
180              used to bind the connection to a specific address.  The
181              bind_address of M-bM-^@M-^\localhostM-bM-^@M-^] indicates that the listening port be
182              bound for local use only, while an empty address or M-bM-^@M-^X*M-bM-^@M-^Y indicates
183              that the port should be available from all interfaces.
184
185      -l login_name
186              Specifies the user to log in as on the remote machine.  This also
187              may be specified on a per-host basis in the configuration file.
188
189      -M      Places the ssh client into M-bM-^@M-^\masterM-bM-^@M-^] mode for connection sharing.
190              Multiple -M options places ssh into M-bM-^@M-^\masterM-bM-^@M-^] mode with
191              confirmation required before slave connections are accepted.
192              Refer to the description of ControlMaster in ssh_config(5) for
193              details.
194
195      -m mac_spec
196              A comma-separated list of MAC (message authentication code)
197              algorithms, specified in order of preference.  See the MACs
198              keyword for more information.
199
200      -N      Do not execute a remote command.  This is useful for just
201              forwarding ports.
202
203      -n      Redirects stdin from /dev/null (actually, prevents reading from
204              stdin).  This must be used when ssh is run in the background.  A
205              common trick is to use this to run X11 programs on a remote
206              machine.  For example, ssh -n shadows.cs.hut.fi emacs & will
207              start an emacs on shadows.cs.hut.fi, and the X11 connection will
208              be automatically forwarded over an encrypted channel.  The ssh
209              program will be put in the background.  (This does not work if
210              ssh needs to ask for a password or passphrase; see also the -f
211              option.)
212
213      -O ctl_cmd
214              Control an active connection multiplexing master process.  When
215              the -O option is specified, the ctl_cmd argument is interpreted
216              and passed to the master process.  Valid commands are: M-bM-^@M-^\checkM-bM-^@M-^]
217              (check that the master process is running), M-bM-^@M-^\forwardM-bM-^@M-^] (request
218              forwardings without command execution), M-bM-^@M-^\cancelM-bM-^@M-^] (cancel
219              forwardings), M-bM-^@M-^\exitM-bM-^@M-^] (request the master to exit), and M-bM-^@M-^\stopM-bM-^@M-^]
220              (request the master to stop accepting further multiplexing
221              requests).
222
223      -o option
224              Can be used to give options in the format used in the
225              configuration file.  This is useful for specifying options for
226              which there is no separate command-line flag.  For full details
227              of the options listed below, and their possible values, see
228              ssh_config(5).
229
230                    AddKeysToAgent
231                    AddressFamily
232                    BatchMode
233                    BindAddress
234                    CanonicalDomains
235                    CanonicalizeFallbackLocal
236                    CanonicalizeHostname
237                    CanonicalizeMaxDots
238                    CanonicalizePermittedCNAMEs
239                    CertificateFile
240                    ChallengeResponseAuthentication
241                    CheckHostIP
242                    Ciphers
243                    ClearAllForwardings
244                    Compression
245                    ConnectionAttempts
246                    ConnectTimeout
247                    ControlMaster
248                    ControlPath
249                    ControlPersist
250                    DynamicForward
251                    EscapeChar
252                    ExitOnForwardFailure
253                    FingerprintHash
254                    ForwardAgent
255                    ForwardX11
256                    ForwardX11Timeout
257                    ForwardX11Trusted
258                    GatewayPorts
259                    GlobalKnownHostsFile
260                    GSSAPIAuthentication
261                    GSSAPIDelegateCredentials
262                    HashKnownHosts
263                    Host
264                    HostbasedAuthentication
265                    HostbasedKeyTypes
266                    HostKeyAlgorithms
267                    HostKeyAlias
268                    HostName
269                    IdentitiesOnly
270                    IdentityAgent
271                    IdentityFile
272                    Include
273                    IPQoS
274                    KbdInteractiveAuthentication
275                    KbdInteractiveDevices
276                    KexAlgorithms
277                    LocalCommand
278                    LocalForward
279                    LogLevel
280                    MACs
281                    Match
282                    NoHostAuthenticationForLocalhost
283                    NumberOfPasswordPrompts
284                    PasswordAuthentication
285                    PermitLocalCommand
286                    PKCS11Provider
287                    Port
288                    PreferredAuthentications
289                    ProxyCommand
290                    ProxyJump
291                    ProxyUseFdpass
292                    PubkeyAcceptedKeyTypes
293                    PubkeyAuthentication
294                    RekeyLimit
295                    RemoteCommand
296                    RemoteForward
297                    RequestTTY
298                    SendEnv
299                    ServerAliveInterval
300                    ServerAliveCountMax
301                    StreamLocalBindMask
302                    StreamLocalBindUnlink
303                    StrictHostKeyChecking
304                    TCPKeepAlive
305                    Tunnel
306                    TunnelDevice
307                    UpdateHostKeys
308                    UsePrivilegedPort
309                    User
310                    UserKnownHostsFile
311                    VerifyHostKeyDNS
312                    VisualHostKey
313                    XAuthLocation
314
315      -p port
316              Port to connect to on the remote host.  This can be specified on
317              a per-host basis in the configuration file.
318
319      -Q query_option
320              Queries ssh for the algorithms supported for the specified
321              version 2.  The available features are: cipher (supported
322              symmetric ciphers), cipher-auth (supported symmetric ciphers that
323              support authenticated encryption), mac (supported message
324              integrity codes), kex (key exchange algorithms), key (key types),
325              key-cert (certificate key types), key-plain (non-certificate key
326              types), and protocol-version (supported SSH protocol versions).
327
328      -q      Quiet mode.  Causes most warning and diagnostic messages to be
329              suppressed.
330
331      -R [bind_address:]port:host:hostport
332      -R [bind_address:]port:local_socket
333      -R remote_socket:host:hostport
334      -R remote_socket:local_socket
335      -R [bind_address:]port
336              Specifies that connections to the given TCP port or Unix socket
337              on the remote (server) host are to be forwarded to the local
338              side.
339
340              This works by allocating a socket to listen to either a TCP port
341              or to a Unix socket on the remote side.  Whenever a connection is
342              made to this port or Unix socket, the connection is forwarded
343              over the secure channel, and a connection is made from the local
344              machine to either an explicit destination specified by host port
345              hostport, or local_socket, or, if no explicit destination was
346              specified, ssh will act as a SOCKS 4/5 proxy and forward
347              connections to the destinations requested by the remote SOCKS
348              client.
349
350              Port forwardings can also be specified in the configuration file.
351              Privileged ports can be forwarded only when logging in as root on
352              the remote machine.  IPv6 addresses can be specified by enclosing
353              the address in square brackets.
354
355              By default, TCP listening sockets on the server will be bound to
356              the loopback interface only.  This may be overridden by
357              specifying a bind_address.  An empty bind_address, or the address
358              M-bM-^@M-^X*M-bM-^@M-^Y, indicates that the remote socket should listen on all
359              interfaces.  Specifying a remote bind_address will only succeed
360              if the server's GatewayPorts option is enabled (see
361              sshd_config(5)).
362
363              If the port argument is M-bM-^@M-^X0M-bM-^@M-^Y, the listen port will be dynamically
364              allocated on the server and reported to the client at run time.
365              When used together with -O forward the allocated port will be
366              printed to the standard output.
367
368      -S ctl_path
369              Specifies the location of a control socket for connection
370              sharing, or the string M-bM-^@M-^\noneM-bM-^@M-^] to disable connection sharing.
371              Refer to the description of ControlPath and ControlMaster in
372              ssh_config(5) for details.
373
374      -s      May be used to request invocation of a subsystem on the remote
375              system.  Subsystems facilitate the use of SSH as a secure
376              transport for other applications (e.g. sftp(1)).  The subsystem
377              is specified as the remote command.
378
379      -T      Disable pseudo-terminal allocation.
380
381      -t      Force pseudo-terminal allocation.  This can be used to execute
382              arbitrary screen-based programs on a remote machine, which can be
383              very useful, e.g. when implementing menu services.  Multiple -t
384              options force tty allocation, even if ssh has no local tty.
385
386      -V      Display the version number and exit.
387
388      -v      Verbose mode.  Causes ssh to print debugging messages about its
389              progress.  This is helpful in debugging connection,
390              authentication, and configuration problems.  Multiple -v options
391              increase the verbosity.  The maximum is 3.
392
393      -W host:port
394              Requests that standard input and output on the client be
395              forwarded to host on port over the secure channel.  Implies -N,
396              -T, ExitOnForwardFailure and ClearAllForwardings, though these
397              can be overridden in the configuration file or using -o command
398              line options.
399
400      -w local_tun[:remote_tun]
401              Requests tunnel device forwarding with the specified tun(4)
402              devices between the client (local_tun) and the server
403              (remote_tun).
404
405              The devices may be specified by numerical ID or the keyword
406              M-bM-^@M-^\anyM-bM-^@M-^], which uses the next available tunnel device.  If
407              remote_tun is not specified, it defaults to M-bM-^@M-^\anyM-bM-^@M-^].  See also the
408              Tunnel and TunnelDevice directives in ssh_config(5).  If the
409              Tunnel directive is unset, it is set to the default tunnel mode,
410              which is M-bM-^@M-^\point-to-pointM-bM-^@M-^].
411
412      -X      Enables X11 forwarding.  This can also be specified on a per-host
413              basis in a configuration file.
414
415              X11 forwarding should be enabled with caution.  Users with the
416              ability to bypass file permissions on the remote host (for the
417              user's X authorization database) can access the local X11 display
418              through the forwarded connection.  An attacker may then be able
419              to perform activities such as keystroke monitoring.
420
421              For this reason, X11 forwarding is subjected to X11 SECURITY
422              extension restrictions by default.  Please refer to the ssh -Y
423              option and the ForwardX11Trusted directive in ssh_config(5) for
424              more information.
425
426      -x      Disables X11 forwarding.
427
428      -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
429              subjected to the X11 SECURITY extension controls.
430
431      -y      Send log information using the syslog(3) system module.  By
432              default this information is sent to stderr.
433
434      ssh may additionally obtain configuration data from a per-user
435      configuration file and a system-wide configuration file.  The file format
436      and configuration options are described in ssh_config(5).
437
438 AUTHENTICATION
439      The OpenSSH SSH client supports SSH protocol 2.
440
441      The methods available for authentication are: GSSAPI-based
442      authentication, host-based authentication, public key authentication,
443      challenge-response authentication, and password authentication.
444      Authentication methods are tried in the order specified above, though
445      PreferredAuthentications can be used to change the default order.
446
447      Host-based authentication works as follows: If the machine the user logs
448      in from is listed in /etc/hosts.equiv or /etc/shosts.equiv on the remote
449      machine, and the user names are the same on both sides, or if the files
450      ~/.rhosts or ~/.shosts exist in the user's home directory on the remote
451      machine and contain a line containing the name of the client machine and
452      the name of the user on that machine, the user is considered for login.
453      Additionally, the server must be able to verify the client's host key
454      (see the description of /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts,
455      below) for login to be permitted.  This authentication method closes
456      security holes due to IP spoofing, DNS spoofing, and routing spoofing.
457      [Note to the administrator: /etc/hosts.equiv, ~/.rhosts, and the
458      rlogin/rsh protocol in general, are inherently insecure and should be
459      disabled if security is desired.]
460
461      Public key authentication works as follows: The scheme is based on
462      public-key cryptography, using cryptosystems where encryption and
463      decryption are done using separate keys, and it is unfeasible to derive
464      the decryption key from the encryption key.  The idea is that each user
465      creates a public/private key pair for authentication purposes.  The
466      server knows the public key, and only the user knows the private key.
467      ssh implements public key authentication protocol automatically, using
468      one of the DSA, ECDSA, Ed25519 or RSA algorithms.  The HISTORY section of
469      ssl(8) contains a brief discussion of the DSA and RSA algorithms.
470
471      The file ~/.ssh/authorized_keys lists the public keys that are permitted
472      for logging in.  When the user logs in, the ssh program tells the server
473      which key pair it would like to use for authentication.  The client
474      proves that it has access to the private key and the server checks that
475      the corresponding public key is authorized to accept the account.
476
477      The server may inform the client of errors that prevented public key
478      authentication from succeeding after authentication completes using a
479      different method.  These may be viewed by increasing the LogLevel to
480      DEBUG or higher (e.g. by using the -v flag).
481
482      The user creates his/her key pair by running ssh-keygen(1).  This stores
483      the private key in ~/.ssh/id_dsa (DSA), ~/.ssh/id_ecdsa (ECDSA),
484      ~/.ssh/id_ed25519 (Ed25519), or ~/.ssh/id_rsa (RSA) and stores the public
485      key in ~/.ssh/id_dsa.pub (DSA), ~/.ssh/id_ecdsa.pub (ECDSA),
486      ~/.ssh/id_ed25519.pub (Ed25519), or ~/.ssh/id_rsa.pub (RSA) in the user's
487      home directory.  The user should then copy the public key to
488      ~/.ssh/authorized_keys in his/her home directory on the remote machine.
489      The authorized_keys file corresponds to the conventional ~/.rhosts file,
490      and has one key per line, though the lines can be very long.  After this,
491      the user can log in without giving the password.
492
493      A variation on public key authentication is available in the form of
494      certificate authentication: instead of a set of public/private keys,
495      signed certificates are used.  This has the advantage that a single
496      trusted certification authority can be used in place of many
497      public/private keys.  See the CERTIFICATES section of ssh-keygen(1) for
498      more information.
499
500      The most convenient way to use public key or certificate authentication
501      may be with an authentication agent.  See ssh-agent(1) and (optionally)
502      the AddKeysToAgent directive in ssh_config(5) for more information.
503
504      Challenge-response authentication works as follows: The server sends an
505      arbitrary "challenge" text, and prompts for a response.  Examples of
506      challenge-response authentication include BSD Authentication (see
507      login.conf(5)) and PAM (some non-OpenBSD systems).
508
509      Finally, if other authentication methods fail, ssh prompts the user for a
510      password.  The password is sent to the remote host for checking; however,
511      since all communications are encrypted, the password cannot be seen by
512      someone listening on the network.
513
514      ssh automatically maintains and checks a database containing
515      identification for all hosts it has ever been used with.  Host keys are
516      stored in ~/.ssh/known_hosts in the user's home directory.  Additionally,
517      the file /etc/ssh/ssh_known_hosts is automatically checked for known
518      hosts.  Any new hosts are automatically added to the user's file.  If a
519      host's identification ever changes, ssh warns about this and disables
520      password authentication to prevent server spoofing or man-in-the-middle
521      attacks, which could otherwise be used to circumvent the encryption.  The
522      StrictHostKeyChecking option can be used to control logins to machines
523      whose host key is not known or has changed.
524
525      When the user's identity has been accepted by the server, the server
526      either executes the given command in a non-interactive session or, if no
527      command has been specified, logs into the machine and gives the user a
528      normal shell as an interactive session.  All communication with the
529      remote command or shell will be automatically encrypted.
530
531      If an interactive session is requested ssh by default will only request a
532      pseudo-terminal (pty) for interactive sessions when the client has one.
533      The flags -T and -t can be used to override this behaviour.
534
535      If a pseudo-terminal has been allocated the user may use the escape
536      characters noted below.
537
538      If no pseudo-terminal has been allocated, the session is transparent and
539      can be used to reliably transfer binary data.  On most systems, setting
540      the escape character to M-bM-^@M-^\noneM-bM-^@M-^] will also make the session transparent
541      even if a tty is used.
542
543      The session terminates when the command or shell on the remote machine
544      exits and all X11 and TCP connections have been closed.
545
546 ESCAPE CHARACTERS
547      When a pseudo-terminal has been requested, ssh supports a number of
548      functions through the use of an escape character.
549
550      A single tilde character can be sent as ~~ or by following the tilde by a
551      character other than those described below.  The escape character must
552      always follow a newline to be interpreted as special.  The escape
553      character can be changed in configuration files using the EscapeChar
554      configuration directive or on the command line by the -e option.
555
556      The supported escapes (assuming the default M-bM-^@M-^X~M-bM-^@M-^Y) are:
557
558      ~.      Disconnect.
559
560      ~^Z     Background ssh.
561
562      ~#      List forwarded connections.
563
564      ~&      Background ssh at logout when waiting for forwarded connection /
565              X11 sessions to terminate.
566
567      ~?      Display a list of escape characters.
568
569      ~B      Send a BREAK to the remote system (only useful if the peer
570              supports it).
571
572      ~C      Open command line.  Currently this allows the addition of port
573              forwardings using the -L, -R and -D options (see above).  It also
574              allows the cancellation of existing port-forwardings with
575              -KL[bind_address:]port for local, -KR[bind_address:]port for
576              remote and -KD[bind_address:]port for dynamic port-forwardings.
577              !command allows the user to execute a local command if the
578              PermitLocalCommand option is enabled in ssh_config(5).  Basic
579              help is available, using the -h option.
580
581      ~R      Request rekeying of the connection (only useful if the peer
582              supports it).
583
584      ~V      Decrease the verbosity (LogLevel) when errors are being written
585              to stderr.
586
587      ~v      Increase the verbosity (LogLevel) when errors are being written
588              to stderr.
589
590 TCP FORWARDING
591      Forwarding of arbitrary TCP connections over the secure channel can be
592      specified either on the command line or in a configuration file.  One
593      possible application of TCP forwarding is a secure connection to a mail
594      server; another is going through firewalls.
595
596      In the example below, we look at encrypting communication between an IRC
597      client and server, even though the IRC server does not directly support
598      encrypted communications.  This works as follows: the user connects to
599      the remote host using ssh, specifying a port to be used to forward
600      connections to the remote server.  After that it is possible to start the
601      service which is to be encrypted on the client machine, connecting to the
602      same local port, and ssh will encrypt and forward the connection.
603
604      The following example tunnels an IRC session from client machine
605      M-bM-^@M-^\127.0.0.1M-bM-^@M-^] (localhost) to remote server M-bM-^@M-^\server.example.comM-bM-^@M-^]:
606
607          $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10
608          $ irc -c '#users' -p 1234 pinky 127.0.0.1
609
610      This tunnels a connection to IRC server M-bM-^@M-^\server.example.comM-bM-^@M-^], joining
611      channel M-bM-^@M-^\#usersM-bM-^@M-^], nickname M-bM-^@M-^\pinkyM-bM-^@M-^], using port 1234.  It doesn't matter
612      which port is used, as long as it's greater than 1023 (remember, only
613      root can open sockets on privileged ports) and doesn't conflict with any
614      ports already in use.  The connection is forwarded to port 6667 on the
615      remote server, since that's the standard port for IRC services.
616
617      The -f option backgrounds ssh and the remote command M-bM-^@M-^\sleep 10M-bM-^@M-^] is
618      specified to allow an amount of time (10 seconds, in the example) to
619      start the service which is to be tunnelled.  If no connections are made
620      within the time specified, ssh will exit.
621
622 X11 FORWARDING
623      If the ForwardX11 variable is set to M-bM-^@M-^\yesM-bM-^@M-^] (or see the description of the
624      -X, -x, and -Y options above) and the user is using X11 (the DISPLAY
625      environment variable is set), the connection to the X11 display is
626      automatically forwarded to the remote side in such a way that any X11
627      programs started from the shell (or command) will go through the
628      encrypted channel, and the connection to the real X server will be made
629      from the local machine.  The user should not manually set DISPLAY.
630      Forwarding of X11 connections can be configured on the command line or in
631      configuration files.
632
633      The DISPLAY value set by ssh will point to the server machine, but with a
634      display number greater than zero.  This is normal, and happens because
635      ssh creates a M-bM-^@M-^\proxyM-bM-^@M-^] X server on the server machine for forwarding the
636      connections over the encrypted channel.
637
638      ssh will also automatically set up Xauthority data on the server machine.
639      For this purpose, it will generate a random authorization cookie, store
640      it in Xauthority on the server, and verify that any forwarded connections
641      carry this cookie and replace it by the real cookie when the connection
642      is opened.  The real authentication cookie is never sent to the server
643      machine (and no cookies are sent in the plain).
644
645      If the ForwardAgent variable is set to M-bM-^@M-^\yesM-bM-^@M-^] (or see the description of
646      the -A and -a options above) and the user is using an authentication
647      agent, the connection to the agent is automatically forwarded to the
648      remote side.
649
650 VERIFYING HOST KEYS
651      When connecting to a server for the first time, a fingerprint of the
652      server's public key is presented to the user (unless the option
653      StrictHostKeyChecking has been disabled).  Fingerprints can be determined
654      using ssh-keygen(1):
655
656            $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
657
658      If the fingerprint is already known, it can be matched and the key can be
659      accepted or rejected.  If only legacy (MD5) fingerprints for the server
660      are available, the ssh-keygen(1) -E option may be used to downgrade the
661      fingerprint algorithm to match.
662
663      Because of the difficulty of comparing host keys just by looking at
664      fingerprint strings, there is also support to compare host keys visually,
665      using random art.  By setting the VisualHostKey option to M-bM-^@M-^\yesM-bM-^@M-^], a small
666      ASCII graphic gets displayed on every login to a server, no matter if the
667      session itself is interactive or not.  By learning the pattern a known
668      server produces, a user can easily find out that the host key has changed
669      when a completely different pattern is displayed.  Because these patterns
670      are not unambiguous however, a pattern that looks similar to the pattern
671      remembered only gives a good probability that the host key is the same,
672      not guaranteed proof.
673
674      To get a listing of the fingerprints along with their random art for all
675      known hosts, the following command line can be used:
676
677            $ ssh-keygen -lv -f ~/.ssh/known_hosts
678
679      If the fingerprint is unknown, an alternative method of verification is
680      available: SSH fingerprints verified by DNS.  An additional resource
681      record (RR), SSHFP, is added to a zonefile and the connecting client is
682      able to match the fingerprint with that of the key presented.
683
684      In this example, we are connecting a client to a server,
685      M-bM-^@M-^\host.example.comM-bM-^@M-^].  The SSHFP resource records should first be added to
686      the zonefile for host.example.com:
687
688            $ ssh-keygen -r host.example.com.
689
690      The output lines will have to be added to the zonefile.  To check that
691      the zone is answering fingerprint queries:
692
693            $ dig -t SSHFP host.example.com
694
695      Finally the client connects:
696
697            $ ssh -o "VerifyHostKeyDNS ask" host.example.com
698            [...]
699            Matching host key fingerprint found in DNS.
700            Are you sure you want to continue connecting (yes/no)?
701
702      See the VerifyHostKeyDNS option in ssh_config(5) for more information.
703
704 SSH-BASED VIRTUAL PRIVATE NETWORKS
705      ssh contains support for Virtual Private Network (VPN) tunnelling using
706      the tun(4) network pseudo-device, allowing two networks to be joined
707      securely.  The sshd_config(5) configuration option PermitTunnel controls
708      whether the server supports this, and at what level (layer 2 or 3
709      traffic).
710
711      The following example would connect client network 10.0.50.0/24 with
712      remote network 10.0.99.0/24 using a point-to-point connection from
713      10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway
714      to the remote network, at 192.168.1.15, allows it.
715
716      On the client:
717
718            # ssh -f -w 0:1 192.168.1.15 true
719            # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
720            # route add 10.0.99.0/24 10.1.1.2
721
722      On the server:
723
724            # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
725            # route add 10.0.50.0/24 10.1.1.1
726
727      Client access may be more finely tuned via the /root/.ssh/authorized_keys
728      file (see below) and the PermitRootLogin server option.  The following
729      entry would permit connections on tun(4) device 1 from user M-bM-^@M-^\janeM-bM-^@M-^] and on
730      tun device 2 from user M-bM-^@M-^\johnM-bM-^@M-^], if PermitRootLogin is set to
731      M-bM-^@M-^\forced-commands-onlyM-bM-^@M-^]:
732
733        tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
734        tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
735
736      Since an SSH-based setup entails a fair amount of overhead, it may be
737      more suited to temporary setups, such as for wireless VPNs.  More
738      permanent VPNs are better provided by tools such as ipsecctl(8) and
739      isakmpd(8).
740
741 ENVIRONMENT
742      ssh will normally set the following environment variables:
743
744      DISPLAY               The DISPLAY variable indicates the location of the
745                            X11 server.  It is automatically set by ssh to
746                            point to a value of the form M-bM-^@M-^\hostname:nM-bM-^@M-^], where
747                            M-bM-^@M-^\hostnameM-bM-^@M-^] indicates the host where the shell runs,
748                            and M-bM-^@M-^XnM-bM-^@M-^Y is an integer M-bM-^IM-% 1.  ssh uses this special
749                            value to forward X11 connections over the secure
750                            channel.  The user should normally not set DISPLAY
751                            explicitly, as that will render the X11 connection
752                            insecure (and will require the user to manually
753                            copy any required authorization cookies).
754
755      HOME                  Set to the path of the user's home directory.
756
757      LOGNAME               Synonym for USER; set for compatibility with
758                            systems that use this variable.
759
760      MAIL                  Set to the path of the user's mailbox.
761
762      PATH                  Set to the default PATH, as specified when
763                            compiling ssh.
764
765      SSH_ASKPASS           If ssh needs a passphrase, it will read the
766                            passphrase from the current terminal if it was run
767                            from a terminal.  If ssh does not have a terminal
768                            associated with it but DISPLAY and SSH_ASKPASS are
769                            set, it will execute the program specified by
770                            SSH_ASKPASS and open an X11 window to read the
771                            passphrase.  This is particularly useful when
772                            calling ssh from a .xsession or related script.
773                            (Note that on some machines it may be necessary to
774                            redirect the input from /dev/null to make this
775                            work.)
776
777      SSH_AUTH_SOCK         Identifies the path of a UNIX-domain socket used to
778                            communicate with the agent.
779
780      SSH_CONNECTION        Identifies the client and server ends of the
781                            connection.  The variable contains four space-
782                            separated values: client IP address, client port
783                            number, server IP address, and server port number.
784
785      SSH_ORIGINAL_COMMAND  This variable contains the original command line if
786                            a forced command is executed.  It can be used to
787                            extract the original arguments.
788
789      SSH_TTY               This is set to the name of the tty (path to the
790                            device) associated with the current shell or
791                            command.  If the current session has no tty, this
792                            variable is not set.
793
794      SSH_TUNNEL            Optionally set by sshd(8) to contain the interface
795                            names assigned if tunnel forwarding was requested
796                            by the client.
797
798      SSH_USER_AUTH         Optionally set by sshd(8), this variable may
799                            contain a pathname to a file that lists the
800                            authentication methods successfully used when the
801                            session was established, including any public keys
802                            that were used.
803
804      TZ                    This variable is set to indicate the present time
805                            zone if it was set when the daemon was started
806                            (i.e. the daemon passes the value on to new
807                            connections).
808
809      USER                  Set to the name of the user logging in.
810
811      Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
812      M-bM-^@M-^\VARNAME=valueM-bM-^@M-^] to the environment if the file exists and users are
813      allowed to change their environment.  For more information, see the
814      PermitUserEnvironment option in sshd_config(5).
815
816 FILES
817      ~/.rhosts
818              This file is used for host-based authentication (see above).  On
819              some machines this file may need to be world-readable if the
820              user's home directory is on an NFS partition, because sshd(8)
821              reads it as root.  Additionally, this file must be owned by the
822              user, and must not have write permissions for anyone else.  The
823              recommended permission for most machines is read/write for the
824              user, and not accessible by others.
825
826      ~/.shosts
827              This file is used in exactly the same way as .rhosts, but allows
828              host-based authentication without permitting login with
829              rlogin/rsh.
830
831      ~/.ssh/
832              This directory is the default location for all user-specific
833              configuration and authentication information.  There is no
834              general requirement to keep the entire contents of this directory
835              secret, but the recommended permissions are read/write/execute
836              for the user, and not accessible by others.
837
838      ~/.ssh/authorized_keys
839              Lists the public keys (DSA, ECDSA, Ed25519, RSA) that can be used
840              for logging in as this user.  The format of this file is
841              described in the sshd(8) manual page.  This file is not highly
842              sensitive, but the recommended permissions are read/write for the
843              user, and not accessible by others.
844
845      ~/.ssh/config
846              This is the per-user configuration file.  The file format and
847              configuration options are described in ssh_config(5).  Because of
848              the potential for abuse, this file must have strict permissions:
849              read/write for the user, and not writable by others.
850
851      ~/.ssh/environment
852              Contains additional definitions for environment variables; see
853              ENVIRONMENT, above.
854
855      ~/.ssh/id_dsa
856      ~/.ssh/id_ecdsa
857      ~/.ssh/id_ed25519
858      ~/.ssh/id_rsa
859              Contains the private key for authentication.  These files contain
860              sensitive data and should be readable by the user but not
861              accessible by others (read/write/execute).  ssh will simply
862              ignore a private key file if it is accessible by others.  It is
863              possible to specify a passphrase when generating the key which
864              will be used to encrypt the sensitive part of this file using
865              AES-128.
866
867      ~/.ssh/id_dsa.pub
868      ~/.ssh/id_ecdsa.pub
869      ~/.ssh/id_ed25519.pub
870      ~/.ssh/id_rsa.pub
871              Contains the public key for authentication.  These files are not
872              sensitive and can (but need not) be readable by anyone.
873
874      ~/.ssh/known_hosts
875              Contains a list of host keys for all hosts the user has logged
876              into that are not already in the systemwide list of known host
877              keys.  See sshd(8) for further details of the format of this
878              file.
879
880      ~/.ssh/rc
881              Commands in this file are executed by ssh when the user logs in,
882              just before the user's shell (or command) is started.  See the
883              sshd(8) manual page for more information.
884
885      /etc/hosts.equiv
886              This file is for host-based authentication (see above).  It
887              should only be writable by root.
888
889      /etc/shosts.equiv
890              This file is used in exactly the same way as hosts.equiv, but
891              allows host-based authentication without permitting login with
892              rlogin/rsh.
893
894      /etc/ssh/ssh_config
895              Systemwide configuration file.  The file format and configuration
896              options are described in ssh_config(5).
897
898      /etc/ssh/ssh_host_key
899      /etc/ssh/ssh_host_dsa_key
900      /etc/ssh/ssh_host_ecdsa_key
901      /etc/ssh/ssh_host_ed25519_key
902      /etc/ssh/ssh_host_rsa_key
903              These files contain the private parts of the host keys and are
904              used for host-based authentication.
905
906      /etc/ssh/ssh_known_hosts
907              Systemwide list of known host keys.  This file should be prepared
908              by the system administrator to contain the public host keys of
909              all machines in the organization.  It should be world-readable.
910              See sshd(8) for further details of the format of this file.
911
912      /etc/ssh/sshrc
913              Commands in this file are executed by ssh when the user logs in,
914              just before the user's shell (or command) is started.  See the
915              sshd(8) manual page for more information.
916
917 EXIT STATUS
918      ssh exits with the exit status of the remote command or with 255 if an
919      error occurred.
920
921 SEE ALSO
922      scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
923      tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
924
925 STANDARDS
926      S. Lehtinen and C. Lonvick, The Secure Shell (SSH) Protocol Assigned
927      Numbers, RFC 4250, January 2006.
928
929      T. Ylonen and C. Lonvick, The Secure Shell (SSH) Protocol Architecture,
930      RFC 4251, January 2006.
931
932      T. Ylonen and C. Lonvick, The Secure Shell (SSH) Authentication Protocol,
933      RFC 4252, January 2006.
934
935      T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer
936      Protocol, RFC 4253, January 2006.
937
938      T. Ylonen and C. Lonvick, The Secure Shell (SSH) Connection Protocol, RFC
939      4254, January 2006.
940
941      J. Schlyter and W. Griffin, Using DNS to Securely Publish Secure Shell
942      (SSH) Key Fingerprints, RFC 4255, January 2006.
943
944      F. Cusack and M. Forssen, Generic Message Exchange Authentication for the
945      Secure Shell Protocol (SSH), RFC 4256, January 2006.
946
947      J. Galbraith and P. Remaker, The Secure Shell (SSH) Session Channel Break
948      Extension, RFC 4335, January 2006.
949
950      M. Bellare, T. Kohno, and C. Namprempre, The Secure Shell (SSH) Transport
951      Layer Encryption Modes, RFC 4344, January 2006.
952
953      B. Harris, Improved Arcfour Modes for the Secure Shell (SSH) Transport
954      Layer Protocol, RFC 4345, January 2006.
955
956      M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
957      the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
958
959      J. Galbraith and R. Thayer, The Secure Shell (SSH) Public Key File
960      Format, RFC 4716, November 2006.
961
962      D. Stebila and J. Green, Elliptic Curve Algorithm Integration in the
963      Secure Shell Transport Layer, RFC 5656, December 2009.
964
965      A. Perrig and D. Song, Hash Visualization: a New Technique to improve
966      Real-World Security, 1999, International Workshop on Cryptographic
967      Techniques and E-Commerce (CrypTEC '99).
968
969 AUTHORS
970      OpenSSH is a derivative of the original and free ssh 1.2.12 release by
971      Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
972      de Raadt and Dug Song removed many bugs, re-added newer features and
973      created OpenSSH.  Markus Friedl contributed the support for SSH protocol
974      versions 1.5 and 2.0.
975
976 OpenBSD 6.2                    February 23, 2018                   OpenBSD 6.2