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

NAME

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

SYNOPSIS

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

DESCRIPTION

15     ssh (SSH client) is a program for logging into a remote machine and for
16     executing commands on a remote machine.  It is intended to replace rlogin
17     and rsh, and provide secure encrypted communications between two
18     untrusted hosts over an insecure network.  X11 connections and arbitrary
19     TCP ports can also be forwarded over the secure channel.
20
21     ssh connects and logs into the specified hostname (with optional user
22     name).  The user must prove his/her identity to the remote machine using
23     one of several methods depending on the protocol version used (see
24     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 and TCP connections).  The
60             compression algorithm is the same used by gzip(1), and the
61             “level” can be controlled by the CompressionLevel option for pro‐
62             tocol version 1.  Compression is desirable on modem lines and
63             other slow connections, but will only slow down things on fast
64             networks.  The default value can be set on a host-by-host basis
65             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”.  3des
72             (triple-des) is an encrypt-decrypt-encrypt triple with three dif‐
73             ferent keys.  It is believed to be secure.  blowfish is a fast
74             block cipher; it appears very secure and is much faster than
75             3des.  des is only supported in the ssh client for interoperabil‐
76             ity with legacy protocol 1 implementations that do not support
77             the 3des cipher.  Its use is strongly discouraged due to crypto‐
78             graphic weaknesses.  The default is “3des”.
79
80             For protocol version 2, cipher_spec is a comma-separated list of
81             ciphers listed in order of preference.  See the Ciphers keyword
82             for more information.
83
84     -D [bind_address:]port
85             Specifies a local “dynamic” application-level port forwarding.
86             This works by allocating a socket to listen to port on the local
87             side, optionally bound to the specified bind_address.  Whenever a
88             connection is made to this port, the connection is forwarded over
89             the secure channel, and the application protocol is then used to
90             determine where to connect to from the remote machine.  Currently
91             the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
92             as a SOCKS server.  Only root can forward privileged ports.
93             Dynamic port forwardings can also be specified in the configura‐
94             tion file.
95
96             IPv6 addresses can be specified with an alternative syntax:
97             [bind_address/]port or by enclosing the address in square brack‐
98             ets.  Only the superuser can forward privileged ports.  By
99             default, the local port is bound in accordance with the
100             GatewayPorts setting.  However, an explicit bind_address may be
101             used to bind the connection to a specific address.  The
102             bind_address of “localhost” indicates that the listening port be
103             bound for local use only, while an empty address or ‘*’ indicates
104             that the port should be available from all interfaces.
105
106     -e escape_char
107             Sets the escape character for sessions with a pty (default: ‘~’).
108             The escape character is only recognized at the beginning of a
109             line.  The escape character followed by a dot (‘.’) closes the
110             connection; followed by control-Z suspends the connection; and
111             followed by itself sends the escape character once.  Setting the
112             character to “none” disables any escapes and makes the session
113             fully transparent.
114
115     -F configfile
116             Specifies an alternative per-user configuration file.  If a con‐
117             figuration file is given on the command line, the system-wide
118             configuration file (/etc/ssh/ssh_config) will be ignored.  The
119             default for the per-user configuration file is ~/.ssh/config.
120
121     -f      Requests ssh to go to background just before command execution.
122             This is useful if ssh is going to ask for passwords or
123             passphrases, but the user wants it in the background.  This
124             implies -n.  The recommended way to start X11 programs at a
125             remote site is with something like ssh -f host xterm.
126
127             If the ExitOnForwardFailure configuration option is set to “yes”,
128             then a client started with -f will wait for all remote port for‐
129             wards to be successfully established before placing itself in the
130             background.
131
132     -g      Allows remote hosts to connect to local forwarded ports.
133
134     -I pkcs11
135             Specify the PKCS#11 shared library ssh should use to communicate
136             with a PKCS#11 token providing the user's private RSA key.
137
138     -i identity_file
139             Selects a file from which the identity (private key) for RSA or
140             DSA authentication is read.  The default is ~/.ssh/identity for
141             protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro‐
142             tocol version 2.  Identity files may also be specified on a per-
143             host basis in the configuration file.  It is possible to have
144             multiple -i options (and multiple identities specified in config‐
145             uration files).  ssh will also try to load certificate informa‐
146             tion from the filename obtained by appending -cert.pub to iden‐
147             tity filenames.
148
149     -K      Enables GSSAPI-based authentication and forwarding (delegation)
150             of GSSAPI credentials to the server.
151
152     -k      Disables forwarding (delegation) of GSSAPI credentials to the
153             server.
154
155     -L [bind_address:]port:host:hostport
156             Specifies that the given port on the local (client) host is to be
157             forwarded to the given host and port on the remote side.  This
158             works by allocating a socket to listen to port on the local side,
159             optionally bound to the specified bind_address.  Whenever a con‐
160             nection is made to this port, the connection is forwarded over
161             the secure channel, and a connection is made to host port
162             hostport from the remote machine.  Port forwardings can also be
163             specified in the configuration file.  IPv6 addresses can be spec‐
164             ified with an alternative syntax:
165             [bind_address/]port/host/hostport or by enclosing the address in
166             square brackets.  Only the superuser can forward privileged
167             ports.  By default, the local port is bound in accordance with
168             the GatewayPorts setting.  However, an explicit bind_address may
169             be used to bind the connection to a specific address.  The
170             bind_address of “localhost” indicates that the listening port be
171             bound for local use only, while an empty address or ‘*’ indicates
172             that the port should be available from all interfaces.
173
174     -l login_name
175             Specifies the user to log in as on the remote machine.  This also
176             may be specified on a per-host basis in the configuration file.
177
178     -M      Places the ssh client into “master” mode for connection sharing.
179             Multiple -M options places ssh into “master” mode with confirma‐
180             tion required before slave connections are accepted.  Refer to
181             the description of ControlMaster in ssh_config(5) for details.
182
183     -m mac_spec
184             Additionally, for protocol version 2 a comma-separated list of
185             MAC (message authentication code) algorithms can be specified in
186             order of preference.  See the MACs keyword for more information.
187
188     -N      Do not execute a remote command.  This is useful for just for‐
189             warding ports (protocol version 2 only).
190
191     -n      Redirects stdin from /dev/null (actually, prevents reading from
192             stdin).  This must be used when ssh is run in the background.  A
193             common trick is to use this to run X11 programs on a remote
194             machine.  For example, ssh -n shadows.cs.hut.fi emacs & will
195             start an emacs on shadows.cs.hut.fi, and the X11 connection will
196             be automatically forwarded over an encrypted channel.  The ssh
197             program will be put in the background.  (This does not work if
198             ssh needs to ask for a password or passphrase; see also the -f
199             option.)
200
201     -O ctl_cmd
202             Control an active connection multiplexing master process.  When
203             the -O option is specified, the ctl_cmd argument is interpreted
204             and passed to the master process.  Valid commands are: “check”
205             (check that the master process is running) and “exit” (request
206             the master to exit).
207
208     -o option
209             Can be used to give options in the format used in the configura‐
210             tion file.  This is useful for specifying options for which there
211             is no separate command-line flag.  For full details of the
212             options listed below, and their possible values, see
213             ssh_config(5).
214
215                   AddressFamily
216                   BatchMode
217                   BindAddress
218                   ChallengeResponseAuthentication
219                   CheckHostIP
220                   Cipher
221                   Ciphers
222                   ClearAllForwardings
223                   Compression
224                   CompressionLevel
225                   ConnectionAttempts
226                   ConnectTimeout
227                   ControlMaster
228                   ControlPath
229                   DynamicForward
230                   EscapeChar
231                   ExitOnForwardFailure
232                   ForwardAgent
233                   ForwardX11
234                   ForwardX11Trusted
235                   GatewayPorts
236                   GlobalKnownHostsFile
237                   GSSAPIAuthentication
238                   GSSAPIDelegateCredentials
239                   HashKnownHosts
240                   Host
241                   HostbasedAuthentication
242                   HostKeyAlgorithms
243                   HostKeyAlias
244                   HostName
245                   IdentityFile
246                   IdentitiesOnly
247                   KbdInteractiveDevices
248                   LocalCommand
249                   LocalForward
250                   LogLevel
251                   MACs
252                   NoHostAuthenticationForLocalhost
253                   NumberOfPasswordPrompts
254                   PasswordAuthentication
255                   PermitLocalCommand
256                   PKCS11Provider
257                   Port
258                   PreferredAuthentications
259                   Protocol
260                   ProxyCommand
261                   PubkeyAuthentication
262                   RekeyLimit
263                   RemoteForward
264                   RhostsRSAAuthentication
265                   RSAAuthentication
266                   SendEnv
267                   ServerAliveInterval
268                   ServerAliveCountMax
269                   StrictHostKeyChecking
270                   TCPKeepAlive
271                   Tunnel
272                   TunnelDevice
273                   UsePrivilegedPort
274                   User
275                   UserKnownHostsFile
276                   VerifyHostKeyDNS
277                   VisualHostKey
278                   XAuthLocation
279
280     -p port
281             Port to connect to on the remote host.  This can be specified on
282             a per-host basis in the configuration file.
283
284     -q      Quiet mode.  Causes most warning and diagnostic messages to be
285             suppressed.
286
287     -R [bind_address:]port:host:hostport
288             Specifies that the given port on the remote (server) host is to
289             be forwarded to the given host and port on the local side.  This
290             works by allocating a socket to listen to port on the remote
291             side, and whenever a connection is made to this port, the connec‐
292             tion is forwarded over the secure channel, and a connection is
293             made to host port hostport from the local machine.
294
295             Port forwardings can also be specified in the configuration file.
296             Privileged ports can be forwarded only when logging in as root on
297             the remote machine.  IPv6 addresses can be specified by enclosing
298             the address in square braces or using an alternative syntax:
299             [bind_address/]host/port/hostport.
300
301             By default, the listening socket on the server will be bound to
302             the loopback interface only.  This may be overridden by specify‐
303             ing a bind_address.  An empty bind_address, or the address ‘*’,
304             indicates that the remote socket should listen on all interfaces.
305             Specifying a remote bind_address will only succeed if the
306             server's GatewayPorts option is enabled (see sshd_config(5)).
307
308             If the port argument is ‘0’, the listen port will be dynamically
309             allocated on the server and reported to the client at run time.
310
311     -S ctl_path
312             Specifies the location of a control socket for connection sharing
313             or the string “none” to disable connection sharing.  Refer to the
314             description of ControlPath and ControlMaster in ssh_config(5) for
315             details.
316
317     -s      May be used to request invocation of a subsystem on the remote
318             system.  Subsystems are a feature of the SSH2 protocol which
319             facilitate the use of SSH as a secure transport for other appli‐
320             cations (eg. sftp(1)).  The subsystem is specified as the remote
321             command.
322
323     -T      Disable pseudo-tty allocation.
324
325     -t      Force pseudo-tty allocation.  This can be used to execute arbi‐
326             trary screen-based programs on a remote machine, which can be
327             very useful, e.g. when implementing menu services.  Multiple -t
328             options force tty allocation, even if ssh has no local tty.
329
330     -V      Display the version number and exit.
331
332     -v      Verbose mode.  Causes ssh to print debugging messages about its
333             progress.  This is helpful in debugging connection, authentica‐
334             tion, and configuration problems.  Multiple -v options increase
335             the verbosity.  The maximum is 3.
336
337     -W host:port
338             Requests that standard input and output on the client be for‐
339             warded to host on port over the secure channel.  Implies -N, -T,
340             ExitOnForwardFailure and ClearAllForwardings and works with Pro‐
341             tocol version 2 only.
342
343     -w local_tun[:remote_tun]
344             Requests tunnel device forwarding with the specified tun(4)
345             devices between the client (local_tun) and the server
346             (remote_tun).
347
348             The devices may be specified by numerical ID or the keyword
349             “any”, which uses the next available tunnel device.  If
350             remote_tun is not specified, it defaults to “any”.  See also the
351             Tunnel and TunnelDevice directives in ssh_config(5).  If the
352             Tunnel directive is unset, it is set to the default tunnel mode,
353             which is “point-to-point”.
354
355     -X      Enables X11 forwarding.  This can also be specified on a per-host
356             basis in a configuration file.
357
358             X11 forwarding should be enabled with caution.  Users with the
359             ability to bypass file permissions on the remote host (for the
360             user's X authorization database) can access the local X11 display
361             through the forwarded connection.  An attacker may then be able
362             to perform activities such as keystroke monitoring.
363
364             For this reason, X11 forwarding is subjected to X11 SECURITY
365             extension restrictions by default.  Please refer to the ssh -Y
366             option and the ForwardX11Trusted directive in ssh_config(5) for
367             more information.
368
369     -x      Disables X11 forwarding.
370
371     -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not
372             subjected to the X11 SECURITY extension controls.
373
374     -y      Send log information using the syslog(3) system module.  By
375             default this information is sent to stderr.
376
377     ssh may additionally obtain configuration data from a per-user configura‐
378     tion file and a system-wide configuration file.  The file format and con‐
379     figuration options are described in ssh_config(5).
380
381     ssh exits with the exit status of the remote command or with 255 if an
382     error occurred.
383

AUTHENTICATION

385     The OpenSSH SSH client supports SSH protocols 1 and 2.  The default is to
386     use protocol 2 only, though this can be changed via the Protocol option
387     in ssh_config(5) or the -1 and -2 options (see above).  Both protocols
388     support similar authentication methods, but protocol 2 is the default
389     since it provides additional mechanisms for confidentiality (the traffic
390     is encrypted using AES, 3DES, Blowfish, CAST128, or Arcfour) and
391     integrity (hmac-md5, hmac-sha1, umac-64, hmac-ripemd160).  Protocol 1
392     lacks a strong mechanism for ensuring the integrity of the connection.
393
394     The methods available for authentication are: GSSAPI-based authentica‐
395     tion, host-based authentication, public key authentication, challenge-
396     response authentication, and password authentication.  Authentication
397     methods are tried in the order specified above, though protocol 2 has a
398     configuration option to change the default order:
399     PreferredAuthentications.
400
401     Host-based authentication works as follows: If the machine the user logs
402     in from is listed in /etc/hosts.equiv or /etc/ssh/shosts.equiv on the
403     remote machine, and the user names are the same on both sides, or if the
404     files ~/.rhosts or ~/.shosts exist in the user's home directory on the
405     remote machine and contain a line containing the name of the client
406     machine and the name of the user on that machine, the user is considered
407     for login.  Additionally, the server must be able to verify the client's
408     host key (see the description of /etc/ssh/ssh_known_hosts and
409     ~/.ssh/known_hosts, below) for login to be permitted.  This authentica‐
410     tion method closes security holes due to IP spoofing, DNS spoofing, and
411     routing spoofing.  [Note to the administrator: /etc/hosts.equiv,
412     ~/.rhosts, and the rlogin/rsh protocol in general, are inherently inse‐
413     cure and should be disabled if security is desired.]
414
415     Public key authentication works as follows: The scheme is based on pub‐
416     lic-key cryptography, using cryptosystems where encryption and decryption
417     are done using separate keys, and it is unfeasible to derive the decryp‐
418     tion key from the encryption key.  The idea is that each user creates a
419     public/private key pair for authentication purposes.  The server knows
420     the public key, and only the user knows the private key.  ssh implements
421     public key authentication protocol automatically, using either the RSA or
422     DSA algorithms.  Protocol 1 is restricted to using only RSA keys, but
423     protocol 2 may use either.  The HISTORY section of ssl(8) contains a
424     brief discussion of the two algorithms.
425
426     The file ~/.ssh/authorized_keys lists the public keys that are permitted
427     for logging in.  When the user logs in, the ssh program tells the server
428     which key pair it would like to use for authentication.  The client
429     proves that it has access to the private key and the server checks that
430     the corresponding public key is authorized to accept the account.
431
432     The user creates his/her key pair by running ssh-keygen(1).  This stores
433     the private key in ~/.ssh/identity (protocol 1), ~/.ssh/id_dsa (protocol
434     2 DSA), or ~/.ssh/id_rsa (protocol 2 RSA) and stores the public key in
435     ~/.ssh/identity.pub (protocol 1), ~/.ssh/id_dsa.pub (protocol 2 DSA), or
436     ~/.ssh/id_rsa.pub (protocol 2 RSA) in the user's home directory.  The
437     user should then copy the public key to ~/.ssh/authorized_keys in his/her
438     home directory on the remote machine.  The authorized_keys file corre‐
439     sponds to the conventional ~/.rhosts file, and has one key per line,
440     though the lines can be very long.  After this, the user can log in with‐
441     out giving the password.
442
443     A variation on public key authentication is available in the form of cer‐
444     tificate authentication: instead of a set of public/private keys, signed
445     certificates are used.  This has the advantage that a single trusted cer‐
446     tification authority can be used in place of many public/private keys.
447     See the CERTIFICATES section of ssh-keygen(1) for more information.
448
449     The most convenient way to use public key or certificate authentication
450     may be with an authentication agent.  See ssh-agent(1) for more informa‐
451     tion.
452
453     Challenge-response authentication works as follows: The server sends an
454     arbitrary "challenge" text, and prompts for a response.  Protocol 2
455     allows multiple challenges and responses; protocol 1 is restricted to
456     just one challenge/response.  Examples of challenge-response authentica‐
457     tion include BSD Authentication (see login.conf(5)) and PAM (some non-
458     OpenBSD systems).
459
460     Finally, if other authentication methods fail, ssh prompts the user for a
461     password.  The password is sent to the remote host for checking; however,
462     since all communications are encrypted, the password cannot be seen by
463     someone listening on the network.
464
465     ssh automatically maintains and checks a database containing identifica‐
466     tion for all hosts it has ever been used with.  Host keys are stored in
467     ~/.ssh/known_hosts in the user's home directory.  Additionally, the file
468     /etc/ssh/ssh_known_hosts is automatically checked for known hosts.  Any
469     new hosts are automatically added to the user's file.  If a host's iden‐
470     tification ever changes, ssh warns about this and disables password
471     authentication to prevent server spoofing or man-in-the-middle attacks,
472     which could otherwise be used to circumvent the encryption.  The
473     StrictHostKeyChecking option can be used to control logins to machines
474     whose host key is not known or has changed.
475
476     When the user's identity has been accepted by the server, the server
477     either executes the given command, or logs into the machine and gives the
478     user a normal shell on the remote machine.  All communication with the
479     remote command or shell will be automatically encrypted.
480
481     If a pseudo-terminal has been allocated (normal login session), the user
482     may use the escape characters noted below.
483
484     If no pseudo-tty has been allocated, the session is transparent and can
485     be used to reliably transfer binary data.  On most systems, setting the
486     escape character to “none” will also make the session transparent even if
487     a tty is used.
488
489     The session terminates when the command or shell on the remote machine
490     exits and all X11 and TCP connections have been closed.
491

ESCAPE CHARACTERS

493     When a pseudo-terminal has been requested, ssh supports a number of func‐
494     tions through the use of an escape character.
495
496     A single tilde character can be sent as ~~ or by following the tilde by a
497     character other than those described below.  The escape character must
498     always follow a newline to be interpreted as special.  The escape charac‐
499     ter can be changed in configuration files using the EscapeChar configura‐
500     tion directive or on the command line by the -e option.
501
502     The supported escapes (assuming the default ‘~’) are:
503
504     ~.      Disconnect.
505
506     ~^Z     Background ssh.
507
508     ~#      List forwarded connections.
509
510     ~&      Background ssh at logout when waiting for forwarded connection /
511             X11 sessions to terminate.
512
513     ~?      Display a list of escape characters.
514
515     ~B      Send a BREAK to the remote system (only useful for SSH protocol
516             version 2 and if the peer supports it).
517
518     ~C      Open command line.  Currently this allows the addition of port
519             forwardings using the -L, -R and -D options (see above).  It also
520             allows the cancellation of existing remote port-forwardings using
521             -KR[bind_address:]port.  !command allows the user to execute a
522             local command if the PermitLocalCommand option is enabled in
523             ssh_config(5).  Basic help is available, using the -h option.
524
525     ~R      Request rekeying of the connection (only useful for SSH protocol
526             version 2 and if the peer supports it).
527

TCP FORWARDING

529     Forwarding of arbitrary TCP connections over the secure channel can be
530     specified either on the command line or in a configuration file.  One
531     possible application of TCP forwarding is a secure connection to a mail
532     server; another is going through firewalls.
533
534     In the example below, we look at encrypting communication between an IRC
535     client and server, even though the IRC server does not directly support
536     encrypted communications.  This works as follows: the user connects to
537     the remote host using ssh, specifying a port to be used to forward con‐
538     nections to the remote server.  After that it is possible to start the
539     service which is to be encrypted on the client machine, connecting to the
540     same local port, and ssh will encrypt and forward the connection.
541
542     The following example tunnels an IRC session from client machine
543     “127.0.0.1” (localhost) to remote server “server.example.com”:
544
545         $ ssh -f -L 1234:localhost:6667 server.example.com sleep 10
546         $ irc -c '#users' -p 1234 pinky 127.0.0.1
547
548     This tunnels a connection to IRC server “server.example.com”, joining
549     channel “#users”, nickname “pinky”, using port 1234.  It doesn't matter
550     which port is used, as long as it's greater than 1023 (remember, only
551     root can open sockets on privileged ports) and doesn't conflict with any
552     ports already in use.  The connection is forwarded to port 6667 on the
553     remote server, since that's the standard port for IRC services.
554
555     The -f option backgrounds ssh and the remote command “sleep 10” is speci‐
556     fied to allow an amount of time (10 seconds, in the example) to start the
557     service which is to be tunnelled.  If no connections are made within the
558     time specified, ssh will exit.
559

X11 FORWARDING

561     If the ForwardX11 variable is set to “yes” (or see the description of the
562     -X, -x, and -Y options above) and the user is using X11 (the DISPLAY
563     environment variable is set), the connection to the X11 display is auto‐
564     matically forwarded to the remote side in such a way that any X11 pro‐
565     grams started from the shell (or command) will go through the encrypted
566     channel, and the connection to the real X server will be made from the
567     local machine.  The user should not manually set DISPLAY.  Forwarding of
568     X11 connections can be configured on the command line or in configuration
569     files.
570
571     The DISPLAY value set by ssh will point to the server machine, but with a
572     display number greater than zero.  This is normal, and happens because
573     ssh creates a “proxy” X server on the server machine for forwarding the
574     connections over the encrypted channel.
575
576     ssh will also automatically set up Xauthority data on the server machine.
577     For this purpose, it will generate a random authorization cookie, store
578     it in Xauthority on the server, and verify that any forwarded connections
579     carry this cookie and replace it by the real cookie when the connection
580     is opened.  The real authentication cookie is never sent to the server
581     machine (and no cookies are sent in the plain).
582
583     If the ForwardAgent variable is set to “yes” (or see the description of
584     the -A and -a options above) and the user is using an authentication
585     agent, the connection to the agent is automatically forwarded to the
586     remote side.
587

VERIFYING HOST KEYS

589     When connecting to a server for the first time, a fingerprint of the
590     server's public key is presented to the user (unless the option
591     StrictHostKeyChecking has been disabled).  Fingerprints can be determined
592     using ssh-keygen(1):
593
594           $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
595
596     If the fingerprint is already known, it can be matched and the key can be
597     accepted or rejected.  Because of the difficulty of comparing host keys
598     just by looking at hex strings, there is also support to compare host
599     keys visually, using random art.  By setting the VisualHostKey option to
600     “yes”, a small ASCII graphic gets displayed on every login to a server,
601     no matter if the session itself is interactive or not.  By learning the
602     pattern a known server produces, a user can easily find out that the host
603     key has changed when a completely different pattern is displayed.
604     Because these patterns are not unambiguous however, a pattern that looks
605     similar to the pattern remembered only gives a good probability that the
606     host key is the same, not guaranteed proof.
607
608     To get a listing of the fingerprints along with their random art for all
609     known hosts, the following command line can be used:
610
611           $ ssh-keygen -lv -f ~/.ssh/known_hosts
612
613     If the fingerprint is unknown, an alternative method of verification is
614     available: SSH fingerprints verified by DNS.  An additional resource
615     record (RR), SSHFP, is added to a zonefile and the connecting client is
616     able to match the fingerprint with that of the key presented.
617
618     In this example, we are connecting a client to a server,
619     “host.example.com”.  The SSHFP resource records should first be added to
620     the zonefile for host.example.com:
621
622           $ ssh-keygen -r host.example.com.
623
624     The output lines will have to be added to the zonefile.  To check that
625     the zone is answering fingerprint queries:
626
627           $ dig -t SSHFP host.example.com
628
629     Finally the client connects:
630
631           $ ssh -o "VerifyHostKeyDNS ask" host.example.com
632           [...]
633           Matching host key fingerprint found in DNS.
634           Are you sure you want to continue connecting (yes/no)?
635
636     See the VerifyHostKeyDNS option in ssh_config(5) for more information.
637

SSH-BASED VIRTUAL PRIVATE NETWORKS

639     ssh contains support for Virtual Private Network (VPN) tunnelling using
640     the tun(4) network pseudo-device, allowing two networks to be joined
641     securely.  The sshd_config(5) configuration option PermitTunnel controls
642     whether the server supports this, and at what level (layer 2 or 3 traf‐
643     fic).
644
645     The following example would connect client network 10.0.50.0/24 with
646     remote network 10.0.99.0/24 using a point-to-point connection from
647     10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway
648     to the remote network, at 192.168.1.15, allows it.
649
650     On the client:
651
652           # ssh -f -w 0:1 192.168.1.15 true
653           # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
654           # route add 10.0.99.0/24 10.1.1.2
655
656     On the server:
657
658           # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
659           # route add 10.0.50.0/24 10.1.1.1
660
661     Client access may be more finely tuned via the /root/.ssh/authorized_keys
662     file (see below) and the PermitRootLogin server option.  The following
663     entry would permit connections on tun(4) device 1 from user “jane” and on
664     tun device 2 from user “john”, if PermitRootLogin is set to
665     “forced-commands-only”:
666
667       tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
668       tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
669
670     Since an SSH-based setup entails a fair amount of overhead, it may be
671     more suited to temporary setups, such as for wireless VPNs.  More perma‐
672     nent VPNs are better provided by tools such as ipsecctl(8) and
673     isakmpd(8).
674

ENVIRONMENT

676     ssh will normally set the following environment variables:
677
678     DISPLAY               The DISPLAY variable indicates the location of the
679                           X11 server.  It is automatically set by ssh to
680                           point to a value of the form “hostname:n”, where
681                           “hostname” indicates the host where the shell runs,
682                           and ‘n’ is an integer ≥ 1.  ssh uses this special
683                           value to forward X11 connections over the secure
684                           channel.  The user should normally not set DISPLAY
685                           explicitly, as that will render the X11 connection
686                           insecure (and will require the user to manually
687                           copy any required authorization cookies).
688
689     HOME                  Set to the path of the user's home directory.
690
691     LOGNAME               Synonym for USER; set for compatibility with sys‐
692                           tems that use this variable.
693
694     MAIL                  Set to the path of the user's mailbox.
695
696     PATH                  Set to the default PATH, as specified when compil‐
697                           ing ssh.
698
699     SSH_ASKPASS           If ssh needs a passphrase, it will read the
700                           passphrase from the current terminal if it was run
701                           from a terminal.  If ssh does not have a terminal
702                           associated with it but DISPLAY and SSH_ASKPASS are
703                           set, it will execute the program specified by
704                           SSH_ASKPASS and open an X11 window to read the
705                           passphrase.  This is particularly useful when call‐
706                           ing ssh from a .xsession or related script.  (Note
707                           that on some machines it may be necessary to redi‐
708                           rect the input from /dev/null to make this work.)
709
710     SSH_AUTH_SOCK         Identifies the path of a UNIX-domain socket used to
711                           communicate with the agent.
712
713     SSH_CONNECTION        Identifies the client and server ends of the con‐
714                           nection.  The variable contains four space-sepa‐
715                           rated values: client IP address, client port num‐
716                           ber, server IP address, and server port number.
717
718     SSH_ORIGINAL_COMMAND  This variable contains the original command line if
719                           a forced command is executed.  It can be used to
720                           extract the original arguments.
721
722     SSH_TTY               This is set to the name of the tty (path to the
723                           device) associated with the current shell or com‐
724                           mand.  If the current session has no tty, this
725                           variable is not set.
726
727     TZ                    This variable is set to indicate the present time
728                           zone if it was set when the daemon was started
729                           (i.e. the daemon passes the value on to new connec‐
730                           tions).
731
732     USER                  Set to the name of the user logging in.
733
734     Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
735     “VARNAME=value” to the environment if the file exists and users are
736     allowed to change their environment.  For more information, see the
737     PermitUserEnvironment option in sshd_config(5).
738

FILES

740     ~/.rhosts
741             This file is used for host-based authentication (see above).  On
742             some machines this file may need to be world-readable if the
743             user's home directory is on an NFS partition, because sshd(8)
744             reads it as root.  Additionally, this file must be owned by the
745             user, and must not have write permissions for anyone else.  The
746             recommended permission for most machines is read/write for the
747             user, and not accessible by others.
748
749     ~/.shosts
750             This file is used in exactly the same way as .rhosts, but allows
751             host-based authentication without permitting login with
752             rlogin/rsh.
753
754     ~/.ssh/
755             This directory is the default location for all user-specific con‐
756             figuration and authentication information.  There is no general
757             requirement to keep the entire contents of this directory secret,
758             but the recommended permissions are read/write/execute for the
759             user, and not accessible by others.
760
761     ~/.ssh/authorized_keys
762             Lists the public keys (RSA/DSA) that can be used for logging in
763             as this user.  The format of this file is described in the
764             sshd(8) manual page.  This file is not highly sensitive, but the
765             recommended permissions are read/write for the user, and not
766             accessible by others.
767
768     ~/.ssh/config
769             This is the per-user configuration file.  The file format and
770             configuration options are described in ssh_config(5).  Because of
771             the potential for abuse, this file must have strict permissions:
772             read/write for the user, and not accessible by others.
773
774     ~/.ssh/environment
775             Contains additional definitions for environment variables; see
776             ENVIRONMENT, above.
777
778     ~/.ssh/identity
779     ~/.ssh/id_dsa
780     ~/.ssh/id_rsa
781             Contains the private key for authentication.  These files contain
782             sensitive data and should be readable by the user but not acces‐
783             sible by others (read/write/execute).  ssh will simply ignore a
784             private key file if it is accessible by others.  It is possible
785             to specify a passphrase when generating the key which will be
786             used to encrypt the sensitive part of this file using 3DES.
787
788     ~/.ssh/identity.pub
789     ~/.ssh/id_dsa.pub
790     ~/.ssh/id_rsa.pub
791             Contains the public key for authentication.  These files are not
792             sensitive and can (but need not) be readable by anyone.
793
794     ~/.ssh/known_hosts
795             Contains a list of host keys for all hosts the user has logged
796             into that are not already in the systemwide list of known host
797             keys.  See sshd(8) for further details of the format of this
798             file.
799
800     ~/.ssh/rc
801             Commands in this file are executed by ssh when the user logs in,
802             just before the user's shell (or command) is started.  See the
803             sshd(8) manual page for more information.
804
805     /etc/hosts.equiv
806             This file is for host-based authentication (see above).  It
807             should only be writable by root.
808
809     /etc/ssh/shosts.equiv
810             This file is used in exactly the same way as hosts.equiv, but
811             allows host-based authentication without permitting login with
812             rlogin/rsh.
813
814     /etc/ssh/ssh_config
815             Systemwide configuration file.  The file format and configuration
816             options are described in ssh_config(5).
817
818     /etc/ssh/ssh_host_key
819     /etc/ssh/ssh_host_dsa_key
820     /etc/ssh/ssh_host_rsa_key
821             These three files contain the private parts of the host keys and
822             are used for host-based authentication.  If protocol version 1 is
823             used, ssh must be setuid root, since the host key is readable
824             only by root.  For protocol version 2, ssh uses ssh-keysign(8) to
825             access the host keys, eliminating the requirement that ssh be
826             setuid root when host-based authentication is used.  By default
827             ssh is not setuid root.
828
829     /etc/ssh/ssh_known_hosts
830             Systemwide list of known host keys.  This file should be prepared
831             by the system administrator to contain the public host keys of
832             all machines in the organization.  It should be world-readable.
833             See sshd(8) for further details of the format of this file.
834
835     /etc/ssh/sshrc
836             Commands in this file are executed by ssh when the user logs in,
837             just before the user's shell (or command) is started.  See the
838             sshd(8) manual page for more information.
839

SEE ALSO

841     scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
842     tun(4), hosts.equiv(5), ssh_config(5), ssh-keysign(8), sshd(8)
843
844     The Secure Shell (SSH) Protocol Assigned Numbers, RFC 4250, 2006.
845
846     The Secure Shell (SSH) Protocol Architecture, RFC 4251, 2006.
847
848     The Secure Shell (SSH) Authentication Protocol, RFC 4252, 2006.
849
850     The Secure Shell (SSH) Transport Layer Protocol, RFC 4253, 2006.
851
852     The Secure Shell (SSH) Connection Protocol, RFC 4254, 2006.
853
854     Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints, RFC
855     4255, 2006.
856
857     Generic Message Exchange Authentication for the Secure Shell Protocol
858     (SSH), RFC 4256, 2006.
859
860     The Secure Shell (SSH) Session Channel Break Extension, RFC 4335, 2006.
861
862     The Secure Shell (SSH) Transport Layer Encryption Modes, RFC 4344, 2006.
863
864     Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer
865     Protocol, RFC 4345, 2006.
866
867     Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer
868     Protocol, RFC 4419, 2006.
869
870     The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006.
871
872     A. Perrig and D. Song, Hash Visualization: a New Technique to improve
873     Real-World Security, 1999, International Workshop on Cryptographic
874     Techniques and E-Commerce (CrypTEC '99).
875

AUTHORS

877     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
878     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
879     de Raadt and Dug Song removed many bugs, re-added newer features and cre‐
880     ated OpenSSH.  Markus Friedl contributed the support for SSH protocol
881     versions 1.5 and 2.0.
882
883BSD                              June 22, 2019                             BSD
Impressum