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

NAME

4     ssh — OpenSSH SSH client (remote login program)
5

SYNOPSIS

7     ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
8         [-D [bind_address:]port] [-E log_file] [-e escape_char]
9         [-F configfile] [-I pkcs11] [-i identity_file]
10         [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
11         [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
12         [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
13         [user@]hostname [command]
14

DESCRIPTION

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

AUTHENTICATION

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

ESCAPE CHARACTERS

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

TCP FORWARDING

594     Forwarding of arbitrary TCP connections over the secure channel can be
595     specified either on the command line or in a configuration file.  One
596     possible application of TCP forwarding is a secure connection to a mail
597     server; another is going through firewalls.
598
599     In the example below, we look at encrypting communication between an IRC
600     client and server, even though the IRC server does not directly support
601     encrypted communications.  This works as follows: the user connects to
602     the remote host using ssh, specifying a port to be used to forward con‐
603     nections to the remote server.  After that it is possible to start the
604     service which is to be encrypted on the client machine, connecting to the
605     same local port, and ssh will encrypt and forward the connection.
606
607     The following example tunnels an IRC session from client machine
608     “127.0.0.1” (localhost) to remote server “server.example.com”:
609
610         $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10
611         $ irc -c '#users' -p 1234 pinky 127.0.0.1
612
613     This tunnels a connection to IRC server “server.example.com”, joining
614     channel “#users”, nickname “pinky”, using port 1234.  It doesn't matter
615     which port is used, as long as it's greater than 1023 (remember, only
616     root can open sockets on privileged ports) and doesn't conflict with any
617     ports already in use.  The connection is forwarded to port 6667 on the
618     remote server, since that's the standard port for IRC services.
619
620     The -f option backgrounds ssh and the remote command “sleep 10” is speci‐
621     fied to allow an amount of time (10 seconds, in the example) to start the
622     service which is to be tunnelled.  If no connections are made within the
623     time specified, ssh will exit.
624

X11 FORWARDING

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

VERIFYING HOST KEYS

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

SSH-BASED VIRTUAL PRIVATE NETWORKS

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

ENVIRONMENT

745     ssh will normally set the following environment variables:
746
747     DISPLAY               The DISPLAY variable indicates the location of the
748                           X11 server.  It is automatically set by ssh to
749                           point to a value of the form “hostname:n”, where
750                           “hostname” indicates the host where the shell runs,
751                           and ‘n’ is an integer ≥ 1.  ssh uses this special
752                           value to forward X11 connections over the secure
753                           channel.  The user should normally not set DISPLAY
754                           explicitly, as that will render the X11 connection
755                           insecure (and will require the user to manually
756                           copy any required authorization cookies).
757
758     HOME                  Set to the path of the user's home directory.
759
760     LOGNAME               Synonym for USER; set for compatibility with sys‐
761                           tems that use this variable.
762
763     MAIL                  Set to the path of the user's mailbox.
764
765     PATH                  Set to the default PATH, as specified when compil‐
766                           ing ssh.
767
768     SSH_ASKPASS           If ssh needs a passphrase, it will read the
769                           passphrase from the current terminal if it was run
770                           from a terminal.  If ssh does not have a terminal
771                           associated with it but DISPLAY and SSH_ASKPASS are
772                           set, it will execute the program specified by
773                           SSH_ASKPASS and open an X11 window to read the
774                           passphrase.  This is particularly useful when call‐
775                           ing ssh from a .xsession or related script.  (Note
776                           that on some machines it may be necessary to redi‐
777                           rect the input from /dev/null to make this work.)
778
779     SSH_AUTH_SOCK         Identifies the path of a UNIX-domain socket used to
780                           communicate with the agent.
781
782     SSH_CONNECTION        Identifies the client and server ends of the con‐
783                           nection.  The variable contains four space-sepa‐
784                           rated values: client IP address, client port num‐
785                           ber, server IP address, and server port number.
786
787     SSH_ORIGINAL_COMMAND  This variable contains the original command line if
788                           a forced command is executed.  It can be used to
789                           extract the original arguments.
790
791     SSH_USER_AUTH         This variable contains, for SSH2 only, a comma-sep‐
792                           arated list of authentication methods that were
793                           successfuly used to authenticate. When possible,
794                           these methods are extended with detailed informa‐
795                           tion on the credential used.
796
797     SSH_TTY               This is set to the name of the tty (path to the
798                           device) associated with the current shell or com‐
799                           mand.  If the current session has no tty, this
800                           variable is not set.
801
802     TZ                    This variable is set to indicate the present time
803                           zone if it was set when the daemon was started
804                           (i.e. the daemon passes the value on to new connec‐
805                           tions).
806
807     USER                  Set to the name of the user logging in.
808
809     Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
810     “VARNAME=value” to the environment if the file exists and users are
811     allowed to change their environment.  For more information, see the
812     PermitUserEnvironment option in sshd_config(5).
813

ENVIRONMENT

815     SSH_USE_STRONG_RNG
816             The reseeding of the OpenSSL random generator is usually done
817             from /dev/urandom.  If the SSH_USE_STRONG_RNG environment vari‐
818             able is set to value other than 0 the OpenSSL random generator is
819             reseeded from /dev/random.  The number of bytes read is defined
820             by the SSH_USE_STRONG_RNG value.  Minimum is 14 bytes.  This set‐
821             ting is not recommended on the computers without the hardware
822             random generator because insufficient entropy causes the connec‐
823             tion to be blocked until enough entropy is available.
824

FILES

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

EXIT STATUS

928     ssh exits with the exit status of the remote command or with 255 if an
929     error occurred.
930

IPV6

932     IPv6 address can be used everywhere where IPv4 address. In all entries
933     must be the IPv6 address enclosed in square brackets. Note: The square
934     brackets are metacharacters for the shell and must be escaped in shell.
935

SEE ALSO

937     scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
938     tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
939

STANDARDS

941     S. Lehtinen and C. Lonvick, The Secure Shell (SSH) Protocol Assigned
942     Numbers, RFC 4250, January 2006.
943
944     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Protocol Architecture,
945     RFC 4251, January 2006.
946
947     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Authentication Protocol,
948     RFC 4252, January 2006.
949
950     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer
951     Protocol, RFC 4253, January 2006.
952
953     T. Ylonen and C. Lonvick, The Secure Shell (SSH) Connection Protocol, RFC
954     4254, January 2006.
955
956     J. Schlyter and W. Griffin, Using DNS to Securely Publish Secure Shell
957     (SSH) Key Fingerprints, RFC 4255, January 2006.
958
959     F. Cusack and M. Forssen, Generic Message Exchange Authentication for the
960     Secure Shell Protocol (SSH), RFC 4256, January 2006.
961
962     J. Galbraith and P. Remaker, The Secure Shell (SSH) Session Channel Break
963     Extension, RFC 4335, January 2006.
964
965     M. Bellare, T. Kohno, and C. Namprempre, The Secure Shell (SSH) Transport
966     Layer Encryption Modes, RFC 4344, January 2006.
967
968     B. Harris, Improved Arcfour Modes for the Secure Shell (SSH) Transport
969     Layer Protocol, RFC 4345, January 2006.
970
971     M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
972     the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
973
974     J. Galbraith and R. Thayer, The Secure Shell (SSH) Public Key File
975     Format, RFC 4716, November 2006.
976
977     D. Stebila and J. Green, Elliptic Curve Algorithm Integration in the
978     Secure Shell Transport Layer, RFC 5656, December 2009.
979
980     A. Perrig and D. Song, Hash Visualization: a New Technique to improve
981     Real-World Security, 1999, International Workshop on Cryptographic
982     Techniques and E-Commerce (CrypTEC '99).
983

AUTHORS

985     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
986     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
987     de Raadt and Dug Song removed many bugs, re-added newer features and cre‐
988     ated OpenSSH.  Markus Friedl contributed the support for SSH protocol
989     versions 1.5 and 2.0.
990
991BSD                              June 21, 2019                             BSD
Impressum