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

AUTHENTICATION

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

ESCAPE CHARACTERS

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

TCP FORWARDING

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

X11 FORWARDING

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

VERIFYING HOST KEYS

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

SSH-BASED VIRTUAL PRIVATE NETWORKS

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

ENVIRONMENT

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

FILES

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

EXIT STATUS

979     ssh exits with the exit status of the remote command or with 255 if an
980     error occurred.
981

IPV6

983     IPv6 address can be used everywhere where IPv4 address. In all entries
984     must be the IPv6 address enclosed in square brackets. Note: The square
985     brackets are metacharacters for the shell and must be escaped in shell.
986

SEE ALSO

988     scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
989     tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
990

STANDARDS

992     S. Lehtinen and C. Lonvick, The Secure Shell (SSH) Protocol Assigned
993     Numbers, RFC 4250, January 2006.
994
995     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Protocol Architecture,
996     RFC 4251, January 2006.
997
998     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Authentication Protocol,
999     RFC 4252, January 2006.
1000
1001     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer
1002     Protocol, RFC 4253, January 2006.
1003
1004     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Connection Protocol, RFC
1005     4254, January 2006.
1006
1007     J. Schlyter and W. Griffin, Using DNS to Securely Publish Secure Shell
1008     (SSH) Key Fingerprints, RFC 4255, January 2006.
1009
1010     F. Cusack and M. Forssen, Generic Message Exchange Authentication for the
1011     Secure Shell Protocol (SSH), RFC 4256, January 2006.
1012
1013     J. Galbraith and P. Remaker, The Secure Shell (SSH) Session Channel Break
1014     Extension, RFC 4335, January 2006.
1015
1016     M. Bellare, T. Kohno, and C. Namprempre, The Secure Shell (SSH) Transport
1017     Layer Encryption Modes, RFC 4344, January 2006.
1018
1019     B. Harris, Improved Arcfour Modes for the Secure Shell (SSH) Transport
1020     Layer Protocol, RFC 4345, January 2006.
1021
1022     M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
1023     the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
1024
1025     J. Galbraith and R. Thayer, The Secure Shell (SSH) Public Key File
1026     Format, RFC 4716, November 2006.
1027
1028     D. Stebila and J. Green, Elliptic Curve Algorithm Integration in the
1029     Secure Shell Transport Layer, RFC 5656, December 2009.
1030
1031     A. Perrig and D. Song, Hash Visualization: a New Technique to improve
1032     Real-World Security, 1999, International Workshop on Cryptographic
1033     Techniques and E-Commerce (CrypTEC '99).
1034

AUTHORS

1036     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
1037     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
1038     de Raadt and Dug Song removed many bugs, re-added newer features and cre‐
1039     ated OpenSSH.  Markus Friedl contributed the support for SSH protocol
1040     versions 1.5 and 2.0.
1041
1042BSD                           September 10, 2021                           BSD
Impressum