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 his/her identity to
25     the remote machine using one of several methods (see below).
26
27     If a command is specified, it is executed on the remote host instead of a
28     login shell.
29
30     The options are as follows:
31
32     -4      Forces ssh to use IPv4 addresses only.
33
34     -6      Forces ssh to use IPv6 addresses only.
35
36     -A      Enables forwarding of 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
59             address.
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
66             default value can be set on a host-by-host basis in the configu‐
67             ration 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.
84             Dynamic port forwardings can also be specified in the configura‐
85             tion 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/gsissh/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
118             implies -n.  The recommended way to start X11 programs at a
119             remote 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.
125
126     -G      Causes ssh to print its configuration after evaluating Host and
127             Match blocks and exit.
128
129     -g      Allows remote hosts to connect to local forwarded ports.  If used
130             on a multiplexed connection, then this option must be specified
131             on the master process.
132
133     -I pkcs11
134             Specify the PKCS#11 shared library ssh should use to communicate
135             with a PKCS#11 token providing keys for user authentication.
136
137     -i identity_file
138             Selects a file from which the identity (private key) for public
139             key authentication is read.  The default is ~/.ssh/id_dsa,
140             ~/.ssh/id_ecdsa, ~/.ssh/id_ecdsa_sk, ~/.ssh/id_ed25519,
141             ~/.ssh/id_ed25519_sk and ~/.ssh/id_rsa.  Identity files may also
142             be specified on a per-host basis in the configuration file.  It
143             is possible to have multiple -i options (and multiple identities
144             specified in configuration files).  If no certificates have been
145             explicitly specified by the CertificateFile directive, ssh will
146             also try to load certificate information from the filename
147             obtained by appending -cert.pub to identity filenames.
148
149     -J destination
150             Connect to the target host by first making a ssh connection to
151             the jump host described by destination and then establishing a
152             TCP forwarding to the ultimate destination from there.  Multiple
153             jump hops may be specified separated by comma characters.  This
154             is a shortcut to specify a ProxyJump configuration directive.
155             Note that configuration directives supplied on the command-line
156             generally apply to the destination host and not any specified
157             jump hosts.  Use ~/.ssh/config to specify configuration for jump
158             hosts.
159
160     -K      Enables GSSAPI-based authentication and forwarding (delegation)
161             of GSSAPI credentials to the server.
162
163     -k      Disables forwarding (delegation) of GSSAPI credentials to the
164             server.
165
166     -L [bind_address:]port:host:hostport
167     -L [bind_address:]port:remote_socket
168     -L local_socket:host:hostport
169     -L local_socket:remote_socket
170             Specifies that connections to the given TCP port or Unix socket
171             on the local (client) host are to be forwarded to the given host
172             and port, or Unix socket, on the remote side.  This works by
173             allocating a socket to listen to either a TCP port on the local
174             side, optionally bound to the specified bind_address, or to a
175             Unix socket.  Whenever a connection is made to the local port or
176             socket, the connection is forwarded over the secure channel, and
177             a connection is made to either host port hostport, or the Unix
178             socket remote_socket, from the remote machine.
179
180             Port forwardings can also be specified in the configuration file.
181             Only the superuser can forward privileged ports.  IPv6 addresses
182             can be specified by enclosing the address in square brackets.
183
184             By default, the local port is bound in accordance with the
185             GatewayPorts setting.  However, an explicit bind_address may be
186             used to bind the connection to a specific address.  The
187             bind_address of “localhost” indicates that the listening port be
188             bound for local use only, while an empty address or ‘*’ indicates
189             that the port should be available from all interfaces.
190
191     -l login_name
192             Specifies the user to log in as on the remote machine.  This also
193             may be specified on a per-host basis in the configuration file.
194
195     -M      Places the ssh client into “master” mode for connection sharing.
196             Multiple -M options places ssh into “master” mode but with con‐
197             firmation required using ssh-askpass(1) before each operation
198             that changes the multiplexing state (e.g. opening a new session).
199             Refer to the description of ControlMaster in ssh_config(5) for
200             details.
201
202     -m mac_spec
203             A comma-separated list of MAC (message authentication code) algo‐
204             rithms, specified in order of preference.  See the MACs keyword
205             for more information.
206
207     -N      Do not execute a remote command.  This is useful for just for‐
208             warding ports.
209
210     -n      Redirects stdin from /dev/null (actually, prevents reading from
211             stdin).  This must be used when ssh is run in the background.  A
212             common trick is to use this to run X11 programs on a remote
213             machine.  For example, ssh -n shadows.cs.hut.fi emacs & will
214             start an emacs on shadows.cs.hut.fi, and the X11 connection will
215             be automatically forwarded over an encrypted channel.  The ssh
216             program will be put in the background.  (This does not work if
217             ssh needs to ask for a password or passphrase; see also the -f
218             option.)
219
220     -O ctl_cmd
221             Control an active connection multiplexing master process.  When
222             the -O option is specified, the ctl_cmd argument is interpreted
223             and passed to the master process.  Valid commands are: “check”
224             (check that the master process is running), “forward” (request
225             forwardings without command execution), “cancel” (cancel forward‐
226             ings), “exit” (request the master to exit), and “stop” (request
227             the master to stop accepting further multiplexing requests).
228
229     -o option
230             Can be used to give options in the format used in the configura‐
231             tion file.  This is useful for specifying options for which there
232             is no separate command-line flag.  For full details of the
233             options listed below, and their possible values, see
234             ssh_config(5).
235
236                   AddKeysToAgent
237                   AddressFamily
238                   BatchMode
239                   BindAddress
240                   CanonicalDomains
241                   CanonicalizeFallbackLocal
242                   CanonicalizeHostname
243                   CanonicalizeMaxDots
244                   CanonicalizePermittedCNAMEs
245                   CASignatureAlgorithms
246                   CertificateFile
247                   ChallengeResponseAuthentication
248                   CheckHostIP
249                   Ciphers
250                   ClearAllForwardings
251                   Compression
252                   ConnectionAttempts
253                   ConnectTimeout
254                   ControlMaster
255                   ControlPath
256                   ControlPersist
257                   DynamicForward
258                   EscapeChar
259                   ExitOnForwardFailure
260                   FingerprintHash
261                   ForwardAgent
262                   ForwardX11
263                   ForwardX11Timeout
264                   ForwardX11Trusted
265                   GatewayPorts
266                   GlobalKnownHostsFile
267                   GSSAPIAuthentication
268                   GSSAPIKeyExchange
269                   GSSAPIClientIdentity
270                   GSSAPIDelegateCredentials
271                   GSSAPIKexAlgorithms
272                   GSSAPIRenewalForcesRekey
273                   GSSAPIServerIdentity
274                   GSSAPITrustDns
275                   HashKnownHosts
276                   Host
277                   HostbasedAuthentication
278                   HostbasedKeyTypes
279                   HostKeyAlgorithms
280                   HostKeyAlias
281                   Hostname
282                   IdentitiesOnly
283                   IdentityAgent
284                   IdentityFile
285                   IPQoS
286                   KbdInteractiveAuthentication
287                   KbdInteractiveDevices
288                   KexAlgorithms
289                   LocalCommand
290                   LocalForward
291                   LogLevel
292                   MACs
293                   Match
294                   NoHostAuthenticationForLocalhost
295                   NumberOfPasswordPrompts
296                   PasswordAuthentication
297                   PermitLocalCommand
298                   PKCS11Provider
299                   Port
300                   PreferredAuthentications
301                   ProxyCommand
302                   ProxyJump
303                   ProxyUseFdpass
304                   PubkeyAcceptedKeyTypes
305                   PubkeyAuthentication
306                   RekeyLimit
307                   RemoteCommand
308                   RemoteForward
309                   RequestTTY
310                   SendEnv
311                   ServerAliveInterval
312                   ServerAliveCountMax
313                   SetEnv
314                   StreamLocalBindMask
315                   StreamLocalBindUnlink
316                   StrictHostKeyChecking
317                   TCPKeepAlive
318                   Tunnel
319                   TunnelDevice
320                   UpdateHostKeys
321                   User
322                   UserKnownHostsFile
323                   VerifyHostKeyDNS
324                   VisualHostKey
325                   XAuthLocation
326
327     -p port
328             Port to connect to on the remote host.  This can be specified on
329             a per-host basis in the configuration file.
330
331     -Q query_option
332             Queries ssh for the algorithms supported for the specified ver‐
333             sion 2.  The available features are: cipher (supported symmetric
334             ciphers), cipher-auth (supported symmetric ciphers that support
335             authenticated encryption), help (supported query terms for use
336             with the -Q flag), mac (supported message integrity codes), kex
337             (key exchange algorithms), kex-gss (GSSAPI key exchange algo‐
338             rithms), key (key types), key-cert (certificate key types),
339             key-plain (non-certificate key types), key-sig (all key types and
340             signature algorithms), protocol-version (supported SSH protocol
341             versions), and sig (supported signature algorithms).  Alterna‐
342             tively, any keyword from ssh_config(5) or sshd_config(5) that
343             takes an algorithm list may be used as an alias for the corre‐
344             sponding query_option.
345
346     -q      Quiet mode.  Causes most warning and diagnostic messages to be
347             suppressed.
348
349     -R [bind_address:]port:host:hostport
350     -R [bind_address:]port:local_socket
351     -R remote_socket:host:hostport
352     -R remote_socket:local_socket
353     -R [bind_address:]port
354             Specifies that connections to the given TCP port or Unix socket
355             on the remote (server) host are to be forwarded to the local
356             side.
357
358             This works by allocating a socket to listen to either a TCP port
359             or to a Unix socket on the remote side.  Whenever a connection is
360             made to this port or Unix socket, the connection is forwarded
361             over the secure channel, and a connection is made from the local
362             machine to either an explicit destination specified by host port
363             hostport, or local_socket, or, if no explicit destination was
364             specified, ssh will act as a SOCKS 4/5 proxy and forward connec‐
365             tions to the destinations requested by the remote SOCKS client.
366
367             Port forwardings can also be specified in the configuration file.
368             Privileged ports can be forwarded only when logging in as root on
369             the remote machine.  IPv6 addresses can be specified by enclosing
370             the address in square brackets.
371
372             By default, TCP listening sockets on the server will be bound to
373             the loopback interface only.  This may be overridden by specify‐
374             ing a bind_address.  An empty bind_address, or the address ‘*’,
375             indicates that the remote socket should listen on all interfaces.
376             Specifying a remote bind_address will only succeed if the
377             server's GatewayPorts option is enabled (see sshd_config(5)).
378
379             If the port argument is ‘0’, the listen port will be dynamically
380             allocated on the server and reported to the client at run time.
381             When used together with -O forward the allocated port will be
382             printed to the standard output.
383
384     -S ctl_path
385             Specifies the location of a control socket for connection shar‐
386             ing, or the string “none” to disable connection sharing.  Refer
387             to the description of ControlPath and ControlMaster in
388             ssh_config(5) for details.
389
390     -s      May be used to request invocation of a subsystem on the remote
391             system.  Subsystems facilitate the use of SSH as a secure trans‐
392             port for other applications (e.g. sftp(1)).  The subsystem is
393             specified as the remote command.
394
395     -T      Disable pseudo-terminal allocation.
396
397     -t      Force pseudo-terminal allocation.  This can be used to execute
398             arbitrary screen-based programs on a remote machine, which can be
399             very useful, e.g. when implementing menu services.  Multiple -t
400             options force tty allocation, even if ssh has no local tty.
401
402     -V      Display the version number and exit.
403
404     -v      Verbose mode.  Causes ssh to print debugging messages about its
405             progress.  This is helpful in debugging connection, authentica‐
406             tion, and configuration problems.  Multiple -v options increase
407             the verbosity.  The maximum is 3.
408
409     -W host:port
410             Requests that standard input and output on the client be for‐
411             warded to host on port over the secure channel.  Implies -N, -T,
412             ExitOnForwardFailure and ClearAllForwardings, though these can be
413             overridden in the configuration file or using -o command line
414             options.
415
416     -w local_tun[:remote_tun]
417             Requests tunnel device forwarding with the specified tun(4)
418             devices between the client (local_tun) and the server
419             (remote_tun).
420
421             The devices may be specified by numerical ID or the keyword
422             “any”, which uses the next available tunnel device.  If
423             remote_tun is not specified, it defaults to “any”.  See also the
424             Tunnel and TunnelDevice directives in ssh_config(5).
425
426             If the Tunnel directive is unset, it will be set to the default
427             tunnel mode, which is “point-to-point”.  If a different Tunnel
428             forwarding mode it desired, then it should be specified before
429             -w.
430
431     -X      Enables X11 forwarding.  This can also be specified on a per-host
432             basis in a configuration file.
433
434             X11 forwarding should be enabled with caution.  Users with the
435             ability to bypass file permissions on the remote host (for the
436             user's X authorization database) can access the local X11 display
437             through the forwarded connection.  An attacker may then be able
438             to perform activities such as keystroke monitoring.
439
440             For this reason, X11 forwarding is subjected to X11 SECURITY
441             extension restrictions by default.  Please refer to the ssh -Y
442             option and the ForwardX11Trusted directive in ssh_config(5) for
443             more information.
444
445     -x      Disables X11 forwarding.
446
447     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
448             subjected to the X11 SECURITY extension controls.
449
450     -y      Send log information using the syslog(3) system module.  By
451             default this information is sent to stderr.
452
453     ssh may additionally obtain configuration data from a per-user configura‐
454     tion file and a system-wide configuration file.  The file format and con‐
455     figuration options are described in ssh_config(5).
456

AUTHENTICATION

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

ESCAPE CHARACTERS

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

TCP FORWARDING

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

X11 FORWARDING

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

VERIFYING HOST KEYS

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

SSH-BASED VIRTUAL PRIVATE NETWORKS

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

ENVIRONMENT

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

FILES

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

EXIT STATUS

959     ssh exits with the exit status of the remote command or with 255 if an
960     error occurred.
961

IPV6

963     IPv6 address can be used everywhere where IPv4 address. In all entries
964     must be the IPv6 address enclosed in square brackets. Note: The square
965     brackets are metacharacters for the shell and must be escaped in shell.
966

SEE ALSO

968     scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
969     tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
970

STANDARDS

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

AUTHORS

1016     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
1017     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
1018     de Raadt and Dug Song removed many bugs, re-added newer features and cre‐
1019     ated OpenSSH.  Markus Friedl contributed the support for SSH protocol
1020     versions 1.5 and 2.0.
1021
1022BSD                              July 15, 2020                             BSD
Impressum