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