1SSH(1)                    BSD General Commands Manual                   SSH(1)
2

NAME

4     ssh — OpenSSH remote login client
5

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

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 speci‐
23     fied as either [user@]hostname or a URI of the form
24     ssh://[user@]hostname[:port].  The user must prove their identity to the
25     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 connections from an authentication agent
37             such as ssh-agent(1).  This can also be specified on a per-host
38             basis in a configuration 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.  A safer alternative may be to use a jump host (see
47             -J).
48
49     -a      Disables forwarding of the authentication agent connection.
50
51     -B bind_interface
52             Bind to the address of bind_interface before attempting to con‐
53             nect to the destination host.  This is only useful on systems
54             with more than one address.
55
56     -b bind_address
57             Use bind_address on the local machine as the source address of
58             the connection.  Only useful on systems with more than one ad‐
59             dress.
60
61     -C      Requests compression of all data (including stdin, stdout,
62             stderr, and data for forwarded X11, TCP and UNIX-domain connec‐
63             tions).  The compression algorithm is the same used by gzip(1).
64             Compression is desirable on modem lines and other slow connec‐
65             tions, but will only slow down things on fast networks.  The de‐
66             fault value can be set on a host-by-host basis in the configura‐
67             tion files; see the Compression option.
68
69     -c cipher_spec
70             Selects the cipher specification for encrypting the session.
71             cipher_spec is a comma-separated list of ciphers listed in order
72             of preference.  See the Ciphers keyword in ssh_config(5) for more
73             information.
74
75     -D [bind_address:]port
76             Specifies a local “dynamic” application-level port forwarding.
77             This works by allocating a socket to listen to port on the local
78             side, optionally bound to the specified bind_address.  Whenever a
79             connection is made to this port, the connection is forwarded over
80             the secure channel, and the application protocol is then used to
81             determine where to connect to from the remote machine.  Currently
82             the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
83             as a SOCKS server.  Only root can forward privileged ports.  Dy‐
84             namic port forwardings can also be specified in the configuration
85             file.
86
87             IPv6 addresses can be specified by enclosing the address in
88             square brackets.  Only the superuser can forward privileged
89             ports.  By default, the local port is bound in accordance with
90             the GatewayPorts setting.  However, an explicit bind_address may
91             be used to bind the connection to a specific address.  The
92             bind_address of “localhost” indicates that the listening port be
93             bound for local use only, while an empty address or ‘*’ indicates
94             that the port should be available from all interfaces.
95
96     -E log_file
97             Append debug logs to log_file instead of standard error.
98
99     -e escape_char
100             Sets the escape character for sessions with a pty (default: ‘~’).
101             The escape character is only recognized at the beginning of a
102             line.  The escape character followed by a dot (‘.’) closes the
103             connection; followed by control-Z suspends the connection; and
104             followed by itself sends the escape character once.  Setting the
105             character to “none” disables any escapes and makes the session
106             fully transparent.
107
108     -F configfile
109             Specifies an alternative per-user configuration file.  If a con‐
110             figuration file is given on the command line, the system-wide
111             configuration file (/etc/ssh/ssh_config) will be ignored.  The
112             default for the per-user configuration file is ~/.ssh/config.  If
113             set to “none”, no configuration files will be read.
114
115     -f      Requests ssh to go to background just before command execution.
116             This is useful if ssh is going to ask for passwords or
117             passphrases, but the user wants it in the background.  This im‐
118             plies -n.  The recommended way to start X11 programs at a remote
119             site is with something like ssh -f host xterm.
120
121             If the ExitOnForwardFailure configuration option is set to “yes”,
122             then a client started with -f will wait for all remote port for‐
123             wards to be successfully established before placing itself in the
124             background.  Refer to the description of ForkAfterAuthentication
125             in ssh_config(5) for details.
126
127     -G      Causes ssh to print its configuration after evaluating Host and
128             Match blocks and exit.
129
130     -g      Allows remote hosts to connect to local forwarded ports.  If used
131             on a multiplexed connection, then this option must be specified
132             on the master process.
133
134     -I pkcs11
135             Specify the PKCS#11 shared library ssh should use to communicate
136             with a PKCS#11 token providing keys for user authentication.
137
138     -i identity_file
139             Selects a file from which the identity (private key) for public
140             key authentication is read.  The default is ~/.ssh/id_dsa,
141             ~/.ssh/id_ecdsa, ~/.ssh/id_ecdsa_sk, ~/.ssh/id_ed25519,
142             ~/.ssh/id_ed25519_sk and ~/.ssh/id_rsa.  Identity files may also
143             be specified on a per-host basis in the configuration file.  It
144             is possible to have multiple -i options (and multiple identities
145             specified in configuration files).  If no certificates have been
146             explicitly specified by the CertificateFile directive, ssh will
147             also try to load certificate information from the filename ob‐
148             tained by appending -cert.pub to identity filenames.
149
150     -J destination
151             Connect to the target host by first making a ssh connection to
152             the jump host described by destination and then establishing a
153             TCP forwarding to the ultimate destination from there.  Multiple
154             jump hops may be specified separated by comma characters.  This
155             is a shortcut to specify a ProxyJump configuration directive.
156             Note that configuration directives supplied on the command-line
157             generally apply to the destination host and not any specified
158             jump hosts.  Use ~/.ssh/config to specify configuration for jump
159             hosts.
160
161     -K      Enables GSSAPI-based authentication and forwarding (delegation)
162             of GSSAPI credentials to the server.
163
164     -k      Disables forwarding (delegation) of GSSAPI credentials to the
165             server.
166
167     -L [bind_address:]port:host:hostport
168     -L [bind_address:]port:remote_socket
169     -L local_socket:host:hostport
170     -L local_socket:remote_socket
171             Specifies that connections to the given TCP port or Unix socket
172             on the local (client) host are to be forwarded to the given host
173             and port, or Unix socket, on the remote side.  This works by al‐
174             locating a socket to listen to either a TCP port on the local
175             side, optionally bound to the specified bind_address, or to a
176             Unix socket.  Whenever a connection is made to the local port or
177             socket, the connection is forwarded over the secure channel, and
178             a connection is made to either host port hostport, or the Unix
179             socket remote_socket, from the remote machine.
180
181             Port forwardings can also be specified in the configuration file.
182             Only the superuser can forward privileged ports.  IPv6 addresses
183             can be specified by enclosing the address in square brackets.
184
185             By default, the local port is bound in accordance with the
186             GatewayPorts setting.  However, an explicit bind_address may be
187             used to bind the connection to a specific address.  The
188             bind_address of “localhost” indicates that the listening port be
189             bound for local use only, while an empty address or ‘*’ indicates
190             that the port should be available from all interfaces.
191
192     -l login_name
193             Specifies the user to log in as on the remote machine.  This also
194             may be specified on a per-host basis in the configuration file.
195
196     -M      Places the ssh client into “master” mode for connection sharing.
197             Multiple -M options places ssh into “master” mode but with con‐
198             firmation required using ssh-askpass(1) before each operation
199             that changes the multiplexing state (e.g. opening a new session).
200             Refer to the description of ControlMaster in ssh_config(5) for
201             details.
202
203     -m mac_spec
204             A comma-separated list of MAC (message authentication code) algo‐
205             rithms, specified in order of preference.  See the MACs keyword
206             for more information.
207
208     -N      Do not execute a remote command.  This is useful for just for‐
209             warding ports.  Refer to the description of SessionType in
210             ssh_config(5) for details.
211
212     -n      Redirects stdin from /dev/null (actually, prevents reading from
213             stdin).  This must be used when ssh is run in the background.  A
214             common trick is to use this to run X11 programs on a remote ma‐
215             chine.  For example, ssh -n shadows.cs.hut.fi emacs & will start
216             an emacs on shadows.cs.hut.fi, and the X11 connection will be au‐
217             tomatically forwarded over an encrypted channel.  The ssh program
218             will be put in the background.  (This does not work if ssh needs
219             to ask for a password or passphrase; see also the -f option.)
220             Refer to the description of StdinNull in ssh_config(5) for de‐
221             tails.
222
223     -O ctl_cmd
224             Control an active connection multiplexing master process.  When
225             the -O option is specified, the ctl_cmd argument is interpreted
226             and passed to the master process.  Valid commands are: “check”
227             (check that the master process is running), “forward” (request
228             forwardings without command execution), “cancel” (cancel forward‐
229             ings), “exit” (request the master to exit), and “stop” (request
230             the master to stop accepting further multiplexing requests).
231
232     -o option
233             Can be used to give options in the format used in the configura‐
234             tion file.  This is useful for specifying options for which there
235             is no separate command-line flag.  For full details of the op‐
236             tions listed below, and their possible values, see ssh_config(5).
237
238                   AddKeysToAgent
239                   AddressFamily
240                   BatchMode
241                   BindAddress
242                   CanonicalDomains
243                   CanonicalizeFallbackLocal
244                   CanonicalizeHostname
245                   CanonicalizeMaxDots
246                   CanonicalizePermittedCNAMEs
247                   CASignatureAlgorithms
248                   CertificateFile
249                   CheckHostIP
250                   Ciphers
251                   ClearAllForwardings
252                   Compression
253                   ConnectionAttempts
254                   ConnectTimeout
255                   ControlMaster
256                   ControlPath
257                   ControlPersist
258                   DynamicForward
259                   EscapeChar
260                   ExitOnForwardFailure
261                   FingerprintHash
262                   ForkAfterAuthentication
263                   ForwardAgent
264                   ForwardX11
265                   ForwardX11Timeout
266                   ForwardX11Trusted
267                   GatewayPorts
268                   GlobalKnownHostsFile
269                   GSSAPIAuthentication
270                   GSSAPIKeyExchange
271                   GSSAPIClientIdentity
272                   GSSAPIDelegateCredentials
273                   GSSAPIKexAlgorithms
274                   GSSAPIRenewalForcesRekey
275                   GSSAPIServerIdentity
276                   GSSAPITrustDns
277                   HashKnownHosts
278                   Host
279                   HostbasedAcceptedAlgorithms
280                   HostbasedAuthentication
281                   HostKeyAlgorithms
282                   HostKeyAlias
283                   Hostname
284                   IdentitiesOnly
285                   IdentityAgent
286                   IdentityFile
287                   IPQoS
288                   KbdInteractiveAuthentication
289                   KbdInteractiveDevices
290                   KexAlgorithms
291                   KnownHostsCommand
292                   LocalCommand
293                   LocalForward
294                   LogLevel
295                   MACs
296                   Match
297                   NoHostAuthenticationForLocalhost
298                   NumberOfPasswordPrompts
299                   PasswordAuthentication
300                   PermitLocalCommand
301                   PermitRemoteOpen
302                   PKCS11Provider
303                   Port
304                   PreferredAuthentications
305                   ProxyCommand
306                   ProxyJump
307                   ProxyUseFdpass
308                   PubkeyAcceptedAlgorithms
309                   PubkeyAuthentication
310                   RekeyLimit
311                   RemoteCommand
312                   RemoteForward
313                   RequestTTY
314                   SendEnv
315                   ServerAliveInterval
316                   ServerAliveCountMax
317                   SessionType
318                   SetEnv
319                   StdinNull
320                   StreamLocalBindMask
321                   StreamLocalBindUnlink
322                   StrictHostKeyChecking
323                   TCPKeepAlive
324                   Tunnel
325                   TunnelDevice
326                   UpdateHostKeys
327                   User
328                   UserKnownHostsFile
329                   VerifyHostKeyDNS
330                   VisualHostKey
331                   XAuthLocation
332
333     -p port
334             Port to connect to on the remote host.  This can be specified on
335             a per-host basis in the configuration file.
336
337     -Q query_option
338             Queries for the algorithms supported by one of the following fea‐
339             tures: cipher (supported symmetric ciphers), cipher-auth (sup‐
340             ported symmetric ciphers that support authenticated encryption),
341             help (supported query terms for use with the -Q flag), mac (sup‐
342             ported message integrity codes), kex (key exchange algorithms),
343             kex-gss (GSSAPI key exchange algorithms), key (key types),
344             key-cert (certificate key types), key-plain (non-certificate key
345             types), key-sig (all key types and signature algorithms),
346             protocol-version (supported SSH protocol versions), and sig (sup‐
347             ported signature algorithms).  Alternatively, any keyword from
348             ssh_config(5) or sshd_config(5) that takes an algorithm list may
349             be used as an alias for the corresponding query_option.
350
351     -q      Quiet mode.  Causes most warning and diagnostic messages to be
352             suppressed.
353
354     -R [bind_address:]port:host:hostport
355     -R [bind_address:]port:local_socket
356     -R remote_socket:host:hostport
357     -R remote_socket:local_socket
358     -R [bind_address:]port
359             Specifies that connections to the given TCP port or Unix socket
360             on the remote (server) host are to be forwarded to the local
361             side.
362
363             This works by allocating a socket to listen to either a TCP port
364             or to a Unix socket on the remote side.  Whenever a connection is
365             made to this port or Unix socket, the connection is forwarded
366             over the secure channel, and a connection is made from the local
367             machine to either an explicit destination specified by host port
368             hostport, or local_socket, or, if no explicit destination was
369             specified, ssh will act as a SOCKS 4/5 proxy and forward connec‐
370             tions to the destinations requested by the remote SOCKS client.
371
372             Port forwardings can also be specified in the configuration file.
373             Privileged ports can be forwarded only when logging in as root on
374             the remote machine.  IPv6 addresses can be specified by enclosing
375             the address in square brackets.
376
377             By default, TCP listening sockets on the server will be bound to
378             the loopback interface only.  This may be overridden by specify‐
379             ing a bind_address.  An empty bind_address, or the address ‘*’,
380             indicates that the remote socket should listen on all interfaces.
381             Specifying a remote bind_address will only succeed if the
382             server's GatewayPorts option is enabled (see sshd_config(5)).
383
384             If the port argument is ‘0’, the listen port will be dynamically
385             allocated on the server and reported to the client at run time.
386             When used together with -O forward the allocated port will be
387             printed to the standard output.
388
389     -S ctl_path
390             Specifies the location of a control socket for connection shar‐
391             ing, or the string “none” to disable connection sharing.  Refer
392             to the description of ControlPath and ControlMaster in
393             ssh_config(5) for details.
394
395     -s      May be used to request invocation of a subsystem on the remote
396             system.  Subsystems facilitate the use of SSH as a secure trans‐
397             port for other applications (e.g. sftp(1)).  The subsystem is
398             specified as the remote command.  Refer to the description of
399             SessionType in ssh_config(5) for details.
400
401     -T      Disable pseudo-terminal allocation.
402
403     -t      Force pseudo-terminal allocation.  This can be used to execute
404             arbitrary screen-based programs on a remote machine, which can be
405             very useful, e.g. when implementing menu services.  Multiple -t
406             options force tty allocation, even if ssh has no local tty.
407
408     -V      Display the version number and exit.
409
410     -v      Verbose mode.  Causes ssh to print debugging messages about its
411             progress.  This is helpful in debugging connection, authentica‐
412             tion, and configuration problems.  Multiple -v options increase
413             the verbosity.  The maximum is 3.
414
415     -W host:port
416             Requests that standard input and output on the client be for‐
417             warded to host on port over the secure channel.  Implies -N, -T,
418             ExitOnForwardFailure and ClearAllForwardings, though these can be
419             overridden in the configuration file or using -o command line op‐
420             tions.
421
422     -w local_tun[:remote_tun]
423             Requests tunnel device forwarding with the specified tun(4) de‐
424             vices between the client (local_tun) and the server (remote_tun).
425
426             The devices may be specified by numerical ID or the keyword
427             “any”, which uses the next available tunnel device.  If
428             remote_tun is not specified, it defaults to “any”.  See also the
429             Tunnel and TunnelDevice directives in ssh_config(5).
430
431             If the Tunnel directive is unset, it will be set to the default
432             tunnel mode, which is “point-to-point”.  If a different Tunnel
433             forwarding mode it desired, then it should be specified before
434             -w.
435
436     -X      Enables X11 forwarding.  This can also be specified on a per-host
437             basis in a configuration file.
438
439             X11 forwarding should be enabled with caution.  Users with the
440             ability to bypass file permissions on the remote host (for the
441             user's X authorization database) can access the local X11 display
442             through the forwarded connection.  An attacker may then be able
443             to perform activities such as keystroke monitoring.
444
445             For this reason, X11 forwarding is subjected to X11 SECURITY ex‐
446             tension restrictions by default.  Please refer to the ssh -Y op‐
447             tion and the ForwardX11Trusted directive in ssh_config(5) for
448             more information.
449
450     -x      Disables X11 forwarding.
451
452     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
453             subjected to the X11 SECURITY extension controls.
454
455     -y      Send log information using the syslog(3) system module.  By de‐
456             fault this information is sent to stderr.
457
458     ssh may additionally obtain configuration data from a per-user configura‐
459     tion file and a system-wide configuration file.  The file format and con‐
460     figuration options are described in ssh_config(5).
461

AUTHENTICATION

463     The OpenSSH SSH client supports SSH protocol 2.
464
465     The methods available for authentication are: GSSAPI-based authentica‐
466     tion, host-based authentication, public key authentication, keyboard-in‐
467     teractive authentication, and password authentication.  Authentication
468     methods are tried in the order specified above, though
469     PreferredAuthentications can be used to change the default order.
470
471     Host-based authentication works as follows: If the machine the user logs
472     in from is listed in /etc/hosts.equiv or /etc/ssh/shosts.equiv on the re‐
473     mote machine, the user is non-root and the user names are the same on
474     both sides, or if the files ~/.rhosts or ~/.shosts exist in the user's
475     home directory on the remote machine and contain a line containing the
476     name of the client machine and the name of the user on that machine, the
477     user is considered for login.  Additionally, the server must be able to
478     verify the client's host key (see the description of
479     /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts, below) for login to be
480     permitted.  This authentication method closes security holes due to IP
481     spoofing, DNS spoofing, and routing spoofing.  [Note to the administra‐
482     tor: /etc/hosts.equiv, ~/.rhosts, and the rlogin/rsh protocol in general,
483     are inherently insecure and should be disabled if security is desired.]
484
485     Public key authentication works as follows: The scheme is based on pub‐
486     lic-key cryptography, using cryptosystems where encryption and decryption
487     are done using separate keys, and it is unfeasible to derive the decryp‐
488     tion key from the encryption key.  The idea is that each user creates a
489     public/private key pair for authentication purposes.  The server knows
490     the public key, and only the user knows the private key.  ssh implements
491     public key authentication protocol automatically, using one of the DSA,
492     ECDSA, Ed25519 or RSA algorithms.  The HISTORY section of ssl(8) contains
493     a brief discussion of the DSA and RSA algorithms.
494
495     The file ~/.ssh/authorized_keys lists the public keys that are permitted
496     for logging in.  When the user logs in, the ssh program tells the server
497     which key pair it would like to use for authentication.  The client
498     proves that it has access to the private key and the server checks that
499     the corresponding public key is authorized to accept the account.
500
501     The server may inform the client of errors that prevented public key au‐
502     thentication from succeeding after authentication completes using a dif‐
503     ferent method.  These may be viewed by increasing the LogLevel to DEBUG
504     or higher (e.g. by using the -v flag).
505
506     The user creates their key pair by running ssh-keygen(1).  This stores
507     the private key in ~/.ssh/id_dsa (DSA), ~/.ssh/id_ecdsa (ECDSA),
508     ~/.ssh/id_ecdsa_sk (authenticator-hosted ECDSA), ~/.ssh/id_ed25519
509     (Ed25519), ~/.ssh/id_ed25519_sk (authenticator-hosted Ed25519), or
510     ~/.ssh/id_rsa (RSA) and stores the public key in ~/.ssh/id_dsa.pub (DSA),
511     ~/.ssh/id_ecdsa.pub (ECDSA), ~/.ssh/id_ecdsa_sk.pub (authenticator-hosted
512     ECDSA), ~/.ssh/id_ed25519.pub (Ed25519), ~/.ssh/id_ed25519_sk.pub (au‐
513     thenticator-hosted Ed25519), or ~/.ssh/id_rsa.pub (RSA) in the user's
514     home directory.  The user should then copy the public key to
515     ~/.ssh/authorized_keys in their home directory on the remote machine.
516     The authorized_keys file corresponds to the conventional ~/.rhosts file,
517     and has one key per line, though the lines can be very long.  After this,
518     the user can log in without giving the password.
519
520     A variation on public key authentication is available in the form of cer‐
521     tificate authentication: instead of a set of public/private keys, signed
522     certificates are used.  This has the advantage that a single trusted cer‐
523     tification authority can be used in place of many public/private keys.
524     See the CERTIFICATES section of ssh-keygen(1) for more information.
525
526     The most convenient way to use public key or certificate authentication
527     may be with an authentication agent.  See ssh-agent(1) and (optionally)
528     the AddKeysToAgent directive in ssh_config(5) for more information.
529
530     Keyboard-interactive authentication works as follows: The server sends an
531     arbitrary "challenge" text and prompts for a response, possibly multiple
532     times.  Examples of keyboard-interactive authentication include BSD Au‐
533     thentication (see login.conf(5)) and PAM (some non-OpenBSD systems).
534
535     Finally, if other authentication methods fail, ssh prompts the user for a
536     password.  The password is sent to the remote host for checking; however,
537     since all communications are encrypted, the password cannot be seen by
538     someone listening on the network.
539
540     ssh automatically maintains and checks a database containing identifica‐
541     tion for all hosts it has ever been used with.  Host keys are stored in
542     ~/.ssh/known_hosts in the user's home directory.  Additionally, the file
543     /etc/ssh/ssh_known_hosts is automatically checked for known hosts.  Any
544     new hosts are automatically added to the user's file.  If a host's iden‐
545     tification ever changes, ssh warns about this and disables password au‐
546     thentication to prevent server spoofing or man-in-the-middle attacks,
547     which could otherwise be used to circumvent the encryption.  The
548     StrictHostKeyChecking option can be used to control logins to machines
549     whose host key is not known or has changed.
550
551     When the user's identity has been accepted by the server, the server ei‐
552     ther executes the given command in a non-interactive session or, if no
553     command has been specified, logs into the machine and gives the user a
554     normal shell as an interactive session.  All communication with the re‐
555     mote command or shell will be automatically encrypted.
556
557     If an interactive session is requested ssh by default will only request a
558     pseudo-terminal (pty) for interactive sessions when the client has one.
559     The flags -T and -t can be used to override this behaviour.
560
561     If a pseudo-terminal has been allocated the user may use the escape char‐
562     acters noted below.
563
564     If no pseudo-terminal has been allocated, the session is transparent and
565     can be used to reliably transfer binary data.  On most systems, setting
566     the escape character to “none” will also make the session transparent
567     even if a tty is used.
568
569     The session terminates when the command or shell on the remote machine
570     exits and all X11 and TCP connections have been closed.
571

ESCAPE CHARACTERS

573     When a pseudo-terminal has been requested, ssh supports a number of func‐
574     tions through the use of an escape character.
575
576     A single tilde character can be sent as ~~ or by following the tilde by a
577     character other than those described below.  The escape character must
578     always follow a newline to be interpreted as special.  The escape charac‐
579     ter can be changed in configuration files using the EscapeChar configura‐
580     tion directive or on the command line by the -e option.
581
582     The supported escapes (assuming the default ‘~’) are:
583
584     ~.      Disconnect.
585
586     ~^Z     Background ssh.
587
588     ~#      List forwarded connections.
589
590     ~&      Background ssh at logout when waiting for forwarded connection /
591             X11 sessions to terminate.
592
593     ~?      Display a list of escape characters.
594
595     ~B      Send a BREAK to the remote system (only useful if the peer sup‐
596             ports it).
597
598     ~C      Open command line.  Currently this allows the addition of port
599             forwardings using the -L, -R and -D options (see above).  It also
600             allows the cancellation of existing port-forwardings with
601             -KL[bind_address:]port for local, -KR[bind_address:]port for re‐
602             mote and -KD[bind_address:]port for dynamic port-forwardings.
603             !command allows the user to execute a local command if the
604             PermitLocalCommand option is enabled in ssh_config(5).  Basic
605             help is available, using the -h option.
606
607     ~R      Request rekeying of the connection (only useful if the peer sup‐
608             ports it).
609
610     ~V      Decrease the verbosity (LogLevel) when errors are being written
611             to stderr.
612
613     ~v      Increase the verbosity (LogLevel) when errors are being written
614             to stderr.
615

TCP FORWARDING

617     Forwarding of arbitrary TCP connections over a secure channel can be
618     specified either on the command line or in a configuration file.  One
619     possible application of TCP forwarding is a secure connection to a mail
620     server; another is going through firewalls.
621
622     In the example below, we look at encrypting communication for an IRC
623     client, even though the IRC server it connects to does not directly sup‐
624     port encrypted communication.  This works as follows: the user connects
625     to the remote host using ssh, specifying the ports to be used to forward
626     the connection.  After that it is possible to start the program locally,
627     and ssh will encrypt and forward the connection to the remote server.
628
629     The following example tunnels an IRC session from the client to an IRC
630     server at “server.example.com”, joining channel “#users”, nickname
631     “pinky”, using the standard IRC port, 6667:
632
633         $ ssh -f -L 6667:localhost:6667 server.example.com sleep 10
634         $ irc -c '#users' pinky IRC/127.0.0.1
635
636     The -f option backgrounds ssh and the remote command “sleep 10” is speci‐
637     fied to allow an amount of time (10 seconds, in the example) to start the
638     program which is going to use the tunnel.  If no connections are made
639     within the time specified, ssh will exit.
640

X11 FORWARDING

642     If the ForwardX11 variable is set to “yes” (or see the description of the
643     -X, -x, and -Y options above) and the user is using X11 (the DISPLAY en‐
644     vironment variable is set), the connection to the X11 display is automat‐
645     ically forwarded to the remote side in such a way that any X11 programs
646     started from the shell (or command) will go through the encrypted chan‐
647     nel, and the connection to the real X server will be made from the local
648     machine.  The user should not manually set DISPLAY.  Forwarding of X11
649     connections can be configured on the command line or in configuration
650     files.
651
652     The DISPLAY value set by ssh will point to the server machine, but with a
653     display number greater than zero.  This is normal, and happens because
654     ssh creates a “proxy” X server on the server machine for forwarding the
655     connections over the encrypted channel.
656
657     ssh will also automatically set up Xauthority data on the server machine.
658     For this purpose, it will generate a random authorization cookie, store
659     it in Xauthority on the server, and verify that any forwarded connections
660     carry this cookie and replace it by the real cookie when the connection
661     is opened.  The real authentication cookie is never sent to the server
662     machine (and no cookies are sent in the plain).
663
664     If the ForwardAgent variable is set to “yes” (or see the description of
665     the -A and -a options above) and the user is using an authentication
666     agent, the connection to the agent is automatically forwarded to the re‐
667     mote side.
668

VERIFYING HOST KEYS

670     When connecting to a server for the first time, a fingerprint of the
671     server's public key is presented to the user (unless the option
672     StrictHostKeyChecking has been disabled).  Fingerprints can be determined
673     using ssh-keygen(1):
674
675           $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
676
677     If the fingerprint is already known, it can be matched and the key can be
678     accepted or rejected.  If only legacy (MD5) fingerprints for the server
679     are available, the ssh-keygen(1) -E option may be used to downgrade the
680     fingerprint algorithm to match.
681
682     Because of the difficulty of comparing host keys just by looking at fin‐
683     gerprint strings, there is also support to compare host keys visually,
684     using random art.  By setting the VisualHostKey option to “yes”, a small
685     ASCII graphic gets displayed on every login to a server, no matter if the
686     session itself is interactive or not.  By learning the pattern a known
687     server produces, a user can easily find out that the host key has changed
688     when a completely different pattern is displayed.  Because these patterns
689     are not unambiguous however, a pattern that looks similar to the pattern
690     remembered only gives a good probability that the host key is the same,
691     not guaranteed proof.
692
693     To get a listing of the fingerprints along with their random art for all
694     known hosts, the following command line can be used:
695
696           $ ssh-keygen -lv -f ~/.ssh/known_hosts
697
698     If the fingerprint is unknown, an alternative method of verification is
699     available: SSH fingerprints verified by DNS.  An additional resource
700     record (RR), SSHFP, is added to a zonefile and the connecting client is
701     able to match the fingerprint with that of the key presented.
702
703     In this example, we are connecting a client to a server,
704     “host.example.com”.  The SSHFP resource records should first be added to
705     the zonefile for host.example.com:
706
707           $ ssh-keygen -r host.example.com.
708
709     The output lines will have to be added to the zonefile.  To check that
710     the zone is answering fingerprint queries:
711
712           $ dig -t SSHFP host.example.com
713
714     Finally the client connects:
715
716           $ ssh -o "VerifyHostKeyDNS ask" host.example.com
717           [...]
718           Matching host key fingerprint found in DNS.
719           Are you sure you want to continue connecting (yes/no)?
720
721     See the VerifyHostKeyDNS option in ssh_config(5) for more information.
722

SSH-BASED VIRTUAL PRIVATE NETWORKS

724     ssh contains support for Virtual Private Network (VPN) tunnelling using
725     the tun(4) network pseudo-device, allowing two networks to be joined se‐
726     curely.  The sshd_config(5) configuration option PermitTunnel controls
727     whether the server supports this, and at what level (layer 2 or 3 traf‐
728     fic).
729
730     The following example would connect client network 10.0.50.0/24 with re‐
731     mote network 10.0.99.0/24 using a point-to-point connection from 10.1.1.1
732     to 10.1.1.2, provided that the SSH server running on the gateway to the
733     remote network, at 192.168.1.15, allows it.
734
735     On the client:
736
737           # ssh -f -w 0:1 192.168.1.15 true
738           # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
739           # route add 10.0.99.0/24 10.1.1.2
740
741     On the server:
742
743           # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
744           # route add 10.0.50.0/24 10.1.1.1
745
746     Client access may be more finely tuned via the /root/.ssh/authorized_keys
747     file (see below) and the PermitRootLogin server option.  The following
748     entry would permit connections on tun(4) device 1 from user “jane” and on
749     tun device 2 from user “john”, if PermitRootLogin is set to
750     “forced-commands-only”:
751
752       tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
753       tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
754
755     Since an SSH-based setup entails a fair amount of overhead, it may be
756     more suited to temporary setups, such as for wireless VPNs.  More perma‐
757     nent VPNs are better provided by tools such as ipsecctl(8) and
758     isakmpd(8).
759

ENVIRONMENT

761     ssh will normally set the following environment variables:
762
763     DISPLAY               The DISPLAY variable indicates the location of the
764                           X11 server.  It is automatically set by ssh to
765                           point to a value of the form “hostname:n”, where
766                           “hostname” indicates the host where the shell runs,
767                           and ‘n’ is an integer ≥ 1.  ssh uses this special
768                           value to forward X11 connections over the secure
769                           channel.  The user should normally not set DISPLAY
770                           explicitly, as that will render the X11 connection
771                           insecure (and will require the user to manually
772                           copy any required authorization cookies).
773
774     HOME                  Set to the path of the user's home directory.
775
776     LOGNAME               Synonym for USER; set for compatibility with sys‐
777                           tems that use this variable.
778
779     MAIL                  Set to the path of the user's mailbox.
780
781     PATH                  Set to the default PATH, as specified when compil‐
782                           ing ssh.
783
784     SSH_ASKPASS           If ssh needs a passphrase, it will read the
785                           passphrase from the current terminal if it was run
786                           from a terminal.  If ssh does not have a terminal
787                           associated with it but DISPLAY and SSH_ASKPASS are
788                           set, it will execute the program specified by
789                           SSH_ASKPASS and open an X11 window to read the
790                           passphrase.  This is particularly useful when call‐
791                           ing ssh from a .xsession or related script.  (Note
792                           that on some machines it may be necessary to redi‐
793                           rect the input from /dev/null to make this work.)
794
795     SSH_ASKPASS_REQUIRE   Allows further control over the use of an askpass
796                           program.  If this variable is set to “never” then
797                           ssh will never attempt to use one.  If it is set to
798                           “prefer”, then ssh will prefer to use the askpass
799                           program instead of the TTY when requesting pass‐
800                           words.  Finally, if the variable is set to “force”,
801                           then the askpass program will be used for all
802                           passphrase input regardless of whether DISPLAY is
803                           set.
804
805     SSH_AUTH_SOCK         Identifies the path of a UNIX-domain socket used to
806                           communicate with the agent.
807
808     SSH_CONNECTION        Identifies the client and server ends of the con‐
809                           nection.  The variable contains four space-sepa‐
810                           rated values: client IP address, client port num‐
811                           ber, server IP address, and server port number.
812
813     SSH_ORIGINAL_COMMAND  This variable contains the original command line if
814                           a forced command is executed.  It can be used to
815                           extract the original arguments.
816
817     SSH_TTY               This is set to the name of the tty (path to the de‐
818                           vice) associated with the current shell or command.
819                           If the current session has no tty, this variable is
820                           not set.
821
822     SSH_TUNNEL            Optionally set by sshd(8) to contain the interface
823                           names assigned if tunnel forwarding was requested
824                           by the client.
825
826     SSH_USER_AUTH         Optionally set by sshd(8), this variable may con‐
827                           tain a pathname to a file that lists the authenti‐
828                           cation methods successfully used when the session
829                           was established, including any public keys that
830                           were used.
831
832     TZ                    This variable is set to indicate the present time
833                           zone if it was set when the daemon was started
834                           (i.e. the daemon passes the value on to new connec‐
835                           tions).
836
837     USER                  Set to the name of the user logging in.
838
839     Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
840     “VARNAME=value” to the environment if the file exists and users are al‐
841     lowed to change their environment.  For more information, see the
842     PermitUserEnvironment option in sshd_config(5).
843

FILES

845     ~/.rhosts
846             This file is used for host-based authentication (see above).  On
847             some machines this file may need to be world-readable if the
848             user's home directory is on an NFS partition, because sshd(8)
849             reads it as root.  Additionally, this file must be owned by the
850             user, and must not have write permissions for anyone else.  The
851             recommended permission for most machines is read/write for the
852             user, and not accessible by others.
853
854     ~/.shosts
855             This file is used in exactly the same way as .rhosts, but allows
856             host-based authentication without permitting login with
857             rlogin/rsh.
858
859     ~/.ssh/
860             This directory is the default location for all user-specific con‐
861             figuration and authentication information.  There is no general
862             requirement to keep the entire contents of this directory secret,
863             but the recommended permissions are read/write/execute for the
864             user, and not accessible by others.
865
866     ~/.ssh/authorized_keys
867             Lists the public keys (DSA, ECDSA, Ed25519, RSA) that can be used
868             for logging in as this user.  The format of this file is de‐
869             scribed in the sshd(8) manual page.  This file is not highly sen‐
870             sitive, but the recommended permissions are read/write for the
871             user, and not accessible by others.
872
873     ~/.ssh/config
874             This is the per-user configuration file.  The file format and
875             configuration options are described in ssh_config(5).  Because of
876             the potential for abuse, this file must have strict permissions:
877             read/write for the user, and not writable by others.
878
879     ~/.ssh/environment
880             Contains additional definitions for environment variables; see
881             ENVIRONMENT, above.
882
883     ~/.ssh/id_dsa
884     ~/.ssh/id_ecdsa
885     ~/.ssh/id_ecdsa_sk
886     ~/.ssh/id_ed25519
887     ~/.ssh/id_ed25519_sk
888     ~/.ssh/id_rsa
889             Contains the private key for authentication.  These files contain
890             sensitive data and should be readable by the user but not acces‐
891             sible by others (read/write/execute).  ssh will simply ignore a
892             private key file if it is accessible by others.  It is possible
893             to specify a passphrase when generating the key which will be
894             used to encrypt the sensitive part of this file using AES-128.
895
896     ~/.ssh/id_dsa.pub
897     ~/.ssh/id_ecdsa.pub
898     ~/.ssh/id_ecdsa_sk.pub
899     ~/.ssh/id_ed25519.pub
900     ~/.ssh/id_ed25519_sk.pub
901     ~/.ssh/id_rsa.pub
902             Contains the public key for authentication.  These files are not
903             sensitive and can (but need not) be readable by anyone.
904
905     ~/.ssh/known_hosts
906             Contains a list of host keys for all hosts the user has logged
907             into that are not already in the systemwide list of known host
908             keys.  See sshd(8) for further details of the format of this
909             file.
910
911     ~/.ssh/rc
912             Commands in this file are executed by ssh when the user logs in,
913             just before the user's shell (or command) is started.  See the
914             sshd(8) manual page for more information.
915
916     /etc/hosts.equiv
917             This file is for host-based authentication (see above).  It
918             should only be writable by root.
919
920     /etc/ssh/shosts.equiv
921             This file is used in exactly the same way as hosts.equiv, but al‐
922             lows host-based authentication without permitting login with
923             rlogin/rsh.
924
925     /etc/ssh/ssh_config
926             Systemwide configuration file.  The file format and configuration
927             options are described in ssh_config(5).
928
929     /etc/ssh/ssh_host_key
930     /etc/ssh/ssh_host_dsa_key
931     /etc/ssh/ssh_host_ecdsa_key
932     /etc/ssh/ssh_host_ed25519_key
933     /etc/ssh/ssh_host_rsa_key
934             These files contain the private parts of the host keys and are
935             used for host-based authentication.
936
937     /etc/ssh/ssh_known_hosts
938             Systemwide list of known host keys.  This file should be prepared
939             by the system administrator to contain the public host keys of
940             all machines in the organization.  It should be world-readable.
941             See sshd(8) for further details of the format of this file.
942
943     /etc/ssh/sshrc
944             Commands in this file are executed by ssh when the user logs in,
945             just before the user's shell (or command) is started.  See the
946             sshd(8) manual page for more information.
947

EXIT STATUS

949     ssh exits with the exit status of the remote command or with 255 if an
950     error occurred.
951

IPV6

953     IPv6 address can be used everywhere where IPv4 address. In all entries
954     must be the IPv6 address enclosed in square brackets. Note: The square
955     brackets are metacharacters for the shell and must be escaped in shell.
956

SEE ALSO

958     scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
959     tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
960

STANDARDS

962     S. Lehtinen and C. Lonvick, The Secure Shell (SSH) Protocol Assigned
963     Numbers, RFC 4250, January 2006.
964
965     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Protocol Architecture,
966     RFC 4251, January 2006.
967
968     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Authentication Protocol,
969     RFC 4252, January 2006.
970
971     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer
972     Protocol, RFC 4253, January 2006.
973
974     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Connection Protocol, RFC
975     4254, January 2006.
976
977     J. Schlyter and W. Griffin, Using DNS to Securely Publish Secure Shell
978     (SSH) Key Fingerprints, RFC 4255, January 2006.
979
980     F. Cusack and M. Forssen, Generic Message Exchange Authentication for the
981     Secure Shell Protocol (SSH), RFC 4256, January 2006.
982
983     J. Galbraith and P. Remaker, The Secure Shell (SSH) Session Channel Break
984     Extension, RFC 4335, January 2006.
985
986     M. Bellare, T. Kohno, and C. Namprempre, The Secure Shell (SSH) Transport
987     Layer Encryption Modes, RFC 4344, January 2006.
988
989     B. Harris, Improved Arcfour Modes for the Secure Shell (SSH) Transport
990     Layer Protocol, RFC 4345, January 2006.
991
992     M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
993     the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
994
995     J. Galbraith and R. Thayer, The Secure Shell (SSH) Public Key File
996     Format, RFC 4716, November 2006.
997
998     D. Stebila and J. Green, Elliptic Curve Algorithm Integration in the
999     Secure Shell Transport Layer, RFC 5656, December 2009.
1000
1001     A. Perrig and D. Song, Hash Visualization: a New Technique to improve
1002     Real-World Security, 1999, International Workshop on Cryptographic
1003     Techniques and E-Commerce (CrypTEC '99).
1004

AUTHORS

1006     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
1007     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
1008     de Raadt and Dug Song removed many bugs, re-added newer features and cre‐
1009     ated OpenSSH.  Markus Friedl contributed the support for SSH protocol
1010     versions 1.5 and 2.0.
1011
1012BSD                              July 28, 2021                             BSD
Impressum