summaryrefslogtreecommitdiff
path: root/ssh.0
diff options
context:
space:
mode:
Diffstat (limited to 'ssh.0')
-rw-r--r--ssh.0992
1 files changed, 992 insertions, 0 deletions
diff --git a/ssh.0 b/ssh.0
new file mode 100644
index 000000000..474bb1e2e
--- /dev/null
+++ b/ssh.0
@@ -0,0 +1,992 @@
1SSH(1) General Commands Manual SSH(1)
2
3NAME
4 ssh M-bM-^@M-^S OpenSSH remote login client
5
6SYNOPSIS
7 ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
8 [-c cipher_spec] [-D [bind_address:]port] [-E log_file]
9 [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
10 [-J destination] [-L address] [-l login_name] [-m mac_spec]
11 [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
12 [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination
13 [command]
14
15DESCRIPTION
16 ssh (SSH client) is a program for logging into a remote machine and for
17 executing commands on a remote machine. It is intended to provide secure
18 encrypted communications between two untrusted hosts over an insecure
19 network. X11 connections, arbitrary TCP ports and UNIX-domain sockets
20 can also be forwarded over the secure channel.
21
22 ssh connects and logs into the specified destination, which may be
23 specified as either [user@]hostname or a URI of the form
24 ssh://[user@]hostname[:port]. The user must prove his/her identity to
25 the remote machine using one of several methods (see below).
26
27 If a command is specified, it is executed on the remote host instead of a
28 login shell.
29
30 The options are as follows:
31
32 -4 Forces ssh to use IPv4 addresses only.
33
34 -6 Forces ssh to use IPv6 addresses only.
35
36 -A Enables forwarding of connections from an authentication agent
37 such as ssh-agent(1). This can also be specified on a per-host
38 basis in a configuration file.
39
40 Agent forwarding should be enabled with caution. Users with the
41 ability to bypass file permissions on the remote host (for the
42 agent's UNIX-domain socket) can access the local agent through
43 the forwarded connection. An attacker cannot obtain key material
44 from the agent, however they can perform operations on the keys
45 that enable them to authenticate using the identities loaded into
46 the agent. A safer alternative may be to use a jump host (see
47 -J).
48
49 -a Disables forwarding of the authentication agent connection.
50
51 -B bind_interface
52 Bind to the address of bind_interface before attempting to
53 connect to the destination host. This is only useful on systems
54 with more than one address.
55
56 -b bind_address
57 Use bind_address on the local machine as the source address of
58 the connection. Only useful on systems with more than one
59 address.
60
61 -C Requests compression of all data (including stdin, stdout,
62 stderr, and data for forwarded X11, TCP and UNIX-domain
63 connections). The compression algorithm is the same used by
64 gzip(1). Compression is desirable on modem lines and other slow
65 connections, but will only slow down things on fast networks.
66 The default value can be set on a host-by-host basis in the
67 configuration files; see the Compression option.
68
69 -c cipher_spec
70 Selects the cipher specification for encrypting the session.
71 cipher_spec is a comma-separated list of ciphers listed in order
72 of preference. See the Ciphers keyword in ssh_config(5) for more
73 information.
74
75 -D [bind_address:]port
76 Specifies a local M-bM-^@M-^\dynamicM-bM-^@M-^] application-level port forwarding.
77 This works by allocating a socket to listen to port on the local
78 side, optionally bound to the specified bind_address. Whenever a
79 connection is made to this port, the connection is forwarded over
80 the secure channel, and the application protocol is then used to
81 determine where to connect to from the remote machine. Currently
82 the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
83 as a SOCKS server. Only root can forward privileged ports.
84 Dynamic port forwardings can also be specified in the
85 configuration file.
86
87 IPv6 addresses can be specified by enclosing the address in
88 square brackets. Only the superuser can forward privileged
89 ports. By default, the local port is bound in accordance with
90 the GatewayPorts setting. However, an explicit bind_address may
91 be used to bind the connection to a specific address. The
92 bind_address of M-bM-^@M-^\localhostM-bM-^@M-^] indicates that the listening port be
93 bound for local use only, while an empty address or M-bM-^@M-^X*M-bM-^@M-^Y indicates
94 that the port should be available from all interfaces.
95
96 -E log_file
97 Append debug logs to log_file instead of standard error.
98
99 -e escape_char
100 Sets the escape character for sessions with a pty (default: M-bM-^@M-^X~M-bM-^@M-^Y).
101 The escape character is only recognized at the beginning of a
102 line. The escape character followed by a dot (M-bM-^@M-^X.M-bM-^@M-^Y) closes the
103 connection; followed by control-Z suspends the connection; and
104 followed by itself sends the escape character once. Setting the
105 character to M-bM-^@M-^\noneM-bM-^@M-^] disables any escapes and makes the session
106 fully transparent.
107
108 -F configfile
109 Specifies an alternative per-user configuration file. If a
110 configuration file is given on the command line, the system-wide
111 configuration file (/etc/ssh/ssh_config) will be ignored. The
112 default for the per-user configuration file is ~/.ssh/config. If
113 set to M-bM-^@M-^\noneM-bM-^@M-^], no configuration files will be read.
114
115 -f Requests ssh to go to background just before command execution.
116 This is useful if ssh is going to ask for passwords or
117 passphrases, but the user wants it in the background. This
118 implies -n. The recommended way to start X11 programs at a
119 remote site is with something like ssh -f host xterm.
120
121 If the ExitOnForwardFailure configuration option is set to M-bM-^@M-^\yesM-bM-^@M-^],
122 then a client started with -f will wait for all remote port
123 forwards to be successfully established before placing itself in
124 the background.
125
126 -G Causes ssh to print its configuration after evaluating Host and
127 Match blocks and exit.
128
129 -g Allows remote hosts to connect to local forwarded ports. If used
130 on a multiplexed connection, then this option must be specified
131 on the master process.
132
133 -I pkcs11
134 Specify the PKCS#11 shared library ssh should use to communicate
135 with a PKCS#11 token providing keys for user authentication.
136
137 -i identity_file
138 Selects a file from which the identity (private key) for public
139 key authentication is read. The default is ~/.ssh/id_dsa,
140 ~/.ssh/id_ecdsa, ~/.ssh/id_ecdsa_sk, ~/.ssh/id_ed25519,
141 ~/.ssh/id_ed25519_sk and ~/.ssh/id_rsa. Identity files may also
142 be specified on a per-host basis in the configuration file. It
143 is possible to have multiple -i options (and multiple identities
144 specified in configuration files). If no certificates have been
145 explicitly specified by the CertificateFile directive, ssh will
146 also try to load certificate information from the filename
147 obtained by appending -cert.pub to identity filenames.
148
149 -J destination
150 Connect to the target host by first making a ssh connection to
151 the jump host described by destination and then establishing a
152 TCP forwarding to the ultimate destination from there. Multiple
153 jump hops may be specified separated by comma characters. This
154 is a shortcut to specify a ProxyJump configuration directive.
155 Note that configuration directives supplied on the command-line
156 generally apply to the destination host and not any specified
157 jump hosts. Use ~/.ssh/config to specify configuration for jump
158 hosts.
159
160 -K Enables GSSAPI-based authentication and forwarding (delegation)
161 of GSSAPI credentials to the server.
162
163 -k Disables forwarding (delegation) of GSSAPI credentials to the
164 server.
165
166 -L [bind_address:]port:host:hostport
167 -L [bind_address:]port:remote_socket
168 -L local_socket:host:hostport
169 -L local_socket:remote_socket
170 Specifies that connections to the given TCP port or Unix socket
171 on the local (client) host are to be forwarded to the given host
172 and port, or Unix socket, on the remote side. This works by
173 allocating a socket to listen to either a TCP port on the local
174 side, optionally bound to the specified bind_address, or to a
175 Unix socket. Whenever a connection is made to the local port or
176 socket, the connection is forwarded over the secure channel, and
177 a connection is made to either host port hostport, or the Unix
178 socket remote_socket, from the remote machine.
179
180 Port forwardings can also be specified in the configuration file.
181 Only the superuser can forward privileged ports. IPv6 addresses
182 can be specified by enclosing the address in square brackets.
183
184 By default, the local port is bound in accordance with the
185 GatewayPorts setting. However, an explicit bind_address may be
186 used to bind the connection to a specific address. The
187 bind_address of M-bM-^@M-^\localhostM-bM-^@M-^] indicates that the listening port be
188 bound for local use only, while an empty address or M-bM-^@M-^X*M-bM-^@M-^Y indicates
189 that the port should be available from all interfaces.
190
191 -l login_name
192 Specifies the user to log in as on the remote machine. This also
193 may be specified on a per-host basis in the configuration file.
194
195 -M Places the ssh client into M-bM-^@M-^\masterM-bM-^@M-^] mode for connection sharing.
196 Multiple -M options places ssh into M-bM-^@M-^\masterM-bM-^@M-^] mode but with
197 confirmation required using ssh-askpass(1) before each operation
198 that changes the multiplexing state (e.g. opening a new session).
199 Refer to the description of ControlMaster in ssh_config(5) for
200 details.
201
202 -m mac_spec
203 A comma-separated list of MAC (message authentication code)
204 algorithms, specified in order of preference. See the MACs
205 keyword for more information.
206
207 -N Do not execute a remote command. This is useful for just
208 forwarding ports.
209
210 -n Redirects stdin from /dev/null (actually, prevents reading from
211 stdin). This must be used when ssh is run in the background. A
212 common trick is to use this to run X11 programs on a remote
213 machine. For example, ssh -n shadows.cs.hut.fi emacs & will
214 start an emacs on shadows.cs.hut.fi, and the X11 connection will
215 be automatically forwarded over an encrypted channel. The ssh
216 program will be put in the background. (This does not work if
217 ssh needs to ask for a password or passphrase; see also the -f
218 option.)
219
220 -O ctl_cmd
221 Control an active connection multiplexing master process. When
222 the -O option is specified, the ctl_cmd argument is interpreted
223 and passed to the master process. Valid commands are: M-bM-^@M-^\checkM-bM-^@M-^]
224 (check that the master process is running), M-bM-^@M-^\forwardM-bM-^@M-^] (request
225 forwardings without command execution), M-bM-^@M-^\cancelM-bM-^@M-^] (cancel
226 forwardings), M-bM-^@M-^\exitM-bM-^@M-^] (request the master to exit), and M-bM-^@M-^\stopM-bM-^@M-^]
227 (request the master to stop accepting further multiplexing
228 requests).
229
230 -o option
231 Can be used to give options in the format used in the
232 configuration file. This is useful for specifying options for
233 which there is no separate command-line flag. For full details
234 of the options listed below, and their possible values, see
235 ssh_config(5).
236
237 AddKeysToAgent
238 AddressFamily
239 BatchMode
240 BindAddress
241 CanonicalDomains
242 CanonicalizeFallbackLocal
243 CanonicalizeHostname
244 CanonicalizeMaxDots
245 CanonicalizePermittedCNAMEs
246 CASignatureAlgorithms
247 CertificateFile
248 ChallengeResponseAuthentication
249 CheckHostIP
250 Ciphers
251 ClearAllForwardings
252 Compression
253 ConnectionAttempts
254 ConnectTimeout
255 ControlMaster
256 ControlPath
257 ControlPersist
258 DynamicForward
259 EscapeChar
260 ExitOnForwardFailure
261 FingerprintHash
262 ForwardAgent
263 ForwardX11
264 ForwardX11Timeout
265 ForwardX11Trusted
266 GatewayPorts
267 GlobalKnownHostsFile
268 GSSAPIAuthentication
269 GSSAPIDelegateCredentials
270 HashKnownHosts
271 Host
272 HostbasedAuthentication
273 HostbasedKeyTypes
274 HostKeyAlgorithms
275 HostKeyAlias
276 Hostname
277 IdentitiesOnly
278 IdentityAgent
279 IdentityFile
280 IPQoS
281 KbdInteractiveAuthentication
282 KbdInteractiveDevices
283 KexAlgorithms
284 LocalCommand
285 LocalForward
286 LogLevel
287 MACs
288 Match
289 NoHostAuthenticationForLocalhost
290 NumberOfPasswordPrompts
291 PasswordAuthentication
292 PermitLocalCommand
293 PKCS11Provider
294 Port
295 PreferredAuthentications
296 ProxyCommand
297 ProxyJump
298 ProxyUseFdpass
299 PubkeyAcceptedKeyTypes
300 PubkeyAuthentication
301 RekeyLimit
302 RemoteCommand
303 RemoteForward
304 RequestTTY
305 SendEnv
306 ServerAliveInterval
307 ServerAliveCountMax
308 SetEnv
309 StreamLocalBindMask
310 StreamLocalBindUnlink
311 StrictHostKeyChecking
312 TCPKeepAlive
313 Tunnel
314 TunnelDevice
315 UpdateHostKeys
316 User
317 UserKnownHostsFile
318 VerifyHostKeyDNS
319 VisualHostKey
320 XAuthLocation
321
322 -p port
323 Port to connect to on the remote host. This can be specified on
324 a per-host basis in the configuration file.
325
326 -Q query_option
327 Queries ssh for the algorithms supported for the specified
328 version 2. The available features are: cipher (supported
329 symmetric ciphers), cipher-auth (supported symmetric ciphers that
330 support authenticated encryption), help (supported query terms
331 for use with the -Q flag), mac (supported message integrity
332 codes), kex (key exchange algorithms), key (key types), key-cert
333 (certificate key types), key-plain (non-certificate key types),
334 key-sig (all key types and signature algorithms),
335 protocol-version (supported SSH protocol versions), and sig
336 (supported signature algorithms). Alternatively, any keyword
337 from ssh_config(5) or sshd_config(5) that takes an algorithm list
338 may be used as an alias for the corresponding query_option.
339
340 -q Quiet mode. Causes most warning and diagnostic messages to be
341 suppressed.
342
343 -R [bind_address:]port:host:hostport
344 -R [bind_address:]port:local_socket
345 -R remote_socket:host:hostport
346 -R remote_socket:local_socket
347 -R [bind_address:]port
348 Specifies that connections to the given TCP port or Unix socket
349 on the remote (server) host are to be forwarded to the local
350 side.
351
352 This works by allocating a socket to listen to either a TCP port
353 or to a Unix socket on the remote side. Whenever a connection is
354 made to this port or Unix socket, the connection is forwarded
355 over the secure channel, and a connection is made from the local
356 machine to either an explicit destination specified by host port
357 hostport, or local_socket, or, if no explicit destination was
358 specified, ssh will act as a SOCKS 4/5 proxy and forward
359 connections to the destinations requested by the remote SOCKS
360 client.
361
362 Port forwardings can also be specified in the configuration file.
363 Privileged ports can be forwarded only when logging in as root on
364 the remote machine. IPv6 addresses can be specified by enclosing
365 the address in square brackets.
366
367 By default, TCP listening sockets on the server will be bound to
368 the loopback interface only. This may be overridden by
369 specifying a bind_address. An empty bind_address, or the address
370 M-bM-^@M-^X*M-bM-^@M-^Y, indicates that the remote socket should listen on all
371 interfaces. Specifying a remote bind_address will only succeed
372 if the server's GatewayPorts option is enabled (see
373 sshd_config(5)).
374
375 If the port argument is M-bM-^@M-^X0M-bM-^@M-^Y, the listen port will be dynamically
376 allocated on the server and reported to the client at run time.
377 When used together with -O forward the allocated port will be
378 printed to the standard output.
379
380 -S ctl_path
381 Specifies the location of a control socket for connection
382 sharing, or the string M-bM-^@M-^\noneM-bM-^@M-^] to disable connection sharing.
383 Refer to the description of ControlPath and ControlMaster in
384 ssh_config(5) for details.
385
386 -s May be used to request invocation of a subsystem on the remote
387 system. Subsystems facilitate the use of SSH as a secure
388 transport for other applications (e.g. sftp(1)). The subsystem
389 is specified as the remote command.
390
391 -T Disable pseudo-terminal allocation.
392
393 -t Force pseudo-terminal allocation. This can be used to execute
394 arbitrary screen-based programs on a remote machine, which can be
395 very useful, e.g. when implementing menu services. Multiple -t
396 options force tty allocation, even if ssh has no local tty.
397
398 -V Display the version number and exit.
399
400 -v Verbose mode. Causes ssh to print debugging messages about its
401 progress. This is helpful in debugging connection,
402 authentication, and configuration problems. Multiple -v options
403 increase the verbosity. The maximum is 3.
404
405 -W host:port
406 Requests that standard input and output on the client be
407 forwarded to host on port over the secure channel. Implies -N,
408 -T, ExitOnForwardFailure and ClearAllForwardings, though these
409 can be overridden in the configuration file or using -o command
410 line options.
411
412 -w local_tun[:remote_tun]
413 Requests tunnel device forwarding with the specified tun(4)
414 devices between the client (local_tun) and the server
415 (remote_tun).
416
417 The devices may be specified by numerical ID or the keyword
418 M-bM-^@M-^\anyM-bM-^@M-^], which uses the next available tunnel device. If
419 remote_tun is not specified, it defaults to M-bM-^@M-^\anyM-bM-^@M-^]. See also the
420 Tunnel and TunnelDevice directives in ssh_config(5).
421
422 If the Tunnel directive is unset, it will be set to the default
423 tunnel mode, which is M-bM-^@M-^\point-to-pointM-bM-^@M-^]. If a different Tunnel
424 forwarding mode it desired, then it should be specified before
425 -w.
426
427 -X Enables X11 forwarding. This can also be specified on a per-host
428 basis in a configuration file.
429
430 X11 forwarding should be enabled with caution. Users with the
431 ability to bypass file permissions on the remote host (for the
432 user's X authorization database) can access the local X11 display
433 through the forwarded connection. An attacker may then be able
434 to perform activities such as keystroke monitoring.
435
436 For this reason, X11 forwarding is subjected to X11 SECURITY
437 extension restrictions by default. Please refer to the ssh -Y
438 option and the ForwardX11Trusted directive in ssh_config(5) for
439 more information.
440
441 -x Disables X11 forwarding.
442
443 -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not
444 subjected to the X11 SECURITY extension controls.
445
446 -y Send log information using the syslog(3) system module. By
447 default this information is sent to stderr.
448
449 ssh may additionally obtain configuration data from a per-user
450 configuration file and a system-wide configuration file. The file format
451 and configuration options are described in ssh_config(5).
452
453AUTHENTICATION
454 The OpenSSH SSH client supports SSH protocol 2.
455
456 The methods available for authentication are: GSSAPI-based
457 authentication, host-based authentication, public key authentication,
458 challenge-response authentication, and password authentication.
459 Authentication methods are tried in the order specified above, though
460 PreferredAuthentications can be used to change the default order.
461
462 Host-based authentication works as follows: If the machine the user logs
463 in from is listed in /etc/hosts.equiv or /etc/shosts.equiv on the remote
464 machine, the user is non-root and the user names are the same on both
465 sides, or if the files ~/.rhosts or ~/.shosts exist in the user's home
466 directory on the remote machine and contain a line containing the name of
467 the client machine and the name of the user on that machine, the user is
468 considered for login. Additionally, the server must be able to verify
469 the client's host key (see the description of /etc/ssh/ssh_known_hosts
470 and ~/.ssh/known_hosts, below) for login to be permitted. This
471 authentication method closes security holes due to IP spoofing, DNS
472 spoofing, and routing spoofing. [Note to the administrator:
473 /etc/hosts.equiv, ~/.rhosts, and the rlogin/rsh protocol in general, are
474 inherently insecure and should be disabled if security is desired.]
475
476 Public key authentication works as follows: The scheme is based on
477 public-key cryptography, using cryptosystems where encryption and
478 decryption are done using separate keys, and it is unfeasible to derive
479 the decryption key from the encryption key. The idea is that each user
480 creates a public/private key pair for authentication purposes. The
481 server knows the public key, and only the user knows the private key.
482 ssh implements public key authentication protocol automatically, using
483 one of the DSA, ECDSA, Ed25519 or RSA algorithms. The HISTORY section of
484 ssl(8) contains a brief discussion of the DSA and RSA algorithms.
485
486 The file ~/.ssh/authorized_keys lists the public keys that are permitted
487 for logging in. When the user logs in, the ssh program tells the server
488 which key pair it would like to use for authentication. The client
489 proves that it has access to the private key and the server checks that
490 the corresponding public key is authorized to accept the account.
491
492 The server may inform the client of errors that prevented public key
493 authentication from succeeding after authentication completes using a
494 different method. These may be viewed by increasing the LogLevel to
495 DEBUG or higher (e.g. by using the -v flag).
496
497 The user creates his/her key pair by running ssh-keygen(1). This stores
498 the private key in ~/.ssh/id_dsa (DSA), ~/.ssh/id_ecdsa (ECDSA),
499 ~/.ssh/id_ecdsa_sk (authenticator-hosted ECDSA), ~/.ssh/id_ed25519
500 (Ed25519), ~/.ssh/id_ed25519_sk (authenticator-hosted Ed25519), or
501 ~/.ssh/id_rsa (RSA) and stores the public key in ~/.ssh/id_dsa.pub (DSA),
502 ~/.ssh/id_ecdsa.pub (ECDSA), ~/.ssh/id_ecdsa_sk.pub (authenticator-hosted
503 ECDSA), ~/.ssh/id_ed25519.pub (Ed25519), ~/.ssh/id_ed25519_sk.pub
504 (authenticator-hosted Ed25519), or ~/.ssh/id_rsa.pub (RSA) in the user's
505 home directory. The user should then copy the public key to
506 ~/.ssh/authorized_keys in his/her home directory on the remote machine.
507 The authorized_keys file corresponds to the conventional ~/.rhosts file,
508 and has one key per line, though the lines can be very long. After this,
509 the user can log in without giving the password.
510
511 A variation on public key authentication is available in the form of
512 certificate authentication: instead of a set of public/private keys,
513 signed certificates are used. This has the advantage that a single
514 trusted certification authority can be used in place of many
515 public/private keys. See the CERTIFICATES section of ssh-keygen(1) for
516 more information.
517
518 The most convenient way to use public key or certificate authentication
519 may be with an authentication agent. See ssh-agent(1) and (optionally)
520 the AddKeysToAgent directive in ssh_config(5) for more information.
521
522 Challenge-response authentication works as follows: The server sends an
523 arbitrary "challenge" text, and prompts for a response. Examples of
524 challenge-response authentication include BSD Authentication (see
525 login.conf(5)) and PAM (some non-OpenBSD systems).
526
527 Finally, if other authentication methods fail, ssh prompts the user for a
528 password. The password is sent to the remote host for checking; however,
529 since all communications are encrypted, the password cannot be seen by
530 someone listening on the network.
531
532 ssh automatically maintains and checks a database containing
533 identification for all hosts it has ever been used with. Host keys are
534 stored in ~/.ssh/known_hosts in the user's home directory. Additionally,
535 the file /etc/ssh/ssh_known_hosts is automatically checked for known
536 hosts. Any new hosts are automatically added to the user's file. If a
537 host's identification ever changes, ssh warns about this and disables
538 password authentication to prevent server spoofing or man-in-the-middle
539 attacks, which could otherwise be used to circumvent the encryption. The
540 StrictHostKeyChecking option can be used to control logins to machines
541 whose host key is not known or has changed.
542
543 When the user's identity has been accepted by the server, the server
544 either executes the given command in a non-interactive session or, if no
545 command has been specified, logs into the machine and gives the user a
546 normal shell as an interactive session. All communication with the
547 remote command or shell will be automatically encrypted.
548
549 If an interactive session is requested ssh by default will only request a
550 pseudo-terminal (pty) for interactive sessions when the client has one.
551 The flags -T and -t can be used to override this behaviour.
552
553 If a pseudo-terminal has been allocated the user may use the escape
554 characters noted below.
555
556 If no pseudo-terminal has been allocated, the session is transparent and
557 can be used to reliably transfer binary data. On most systems, setting
558 the escape character to M-bM-^@M-^\noneM-bM-^@M-^] will also make the session transparent
559 even if a tty is used.
560
561 The session terminates when the command or shell on the remote machine
562 exits and all X11 and TCP connections have been closed.
563
564ESCAPE CHARACTERS
565 When a pseudo-terminal has been requested, ssh supports a number of
566 functions through the use of an escape character.
567
568 A single tilde character can be sent as ~~ or by following the tilde by a
569 character other than those described below. The escape character must
570 always follow a newline to be interpreted as special. The escape
571 character can be changed in configuration files using the EscapeChar
572 configuration directive or on the command line by the -e option.
573
574 The supported escapes (assuming the default M-bM-^@M-^X~M-bM-^@M-^Y) are:
575
576 ~. Disconnect.
577
578 ~^Z Background ssh.
579
580 ~# List forwarded connections.
581
582 ~& Background ssh at logout when waiting for forwarded connection /
583 X11 sessions to terminate.
584
585 ~? Display a list of escape characters.
586
587 ~B Send a BREAK to the remote system (only useful if the peer
588 supports it).
589
590 ~C Open command line. Currently this allows the addition of port
591 forwardings using the -L, -R and -D options (see above). It also
592 allows the cancellation of existing port-forwardings with
593 -KL[bind_address:]port for local, -KR[bind_address:]port for
594 remote and -KD[bind_address:]port for dynamic port-forwardings.
595 !command allows the user to execute a local command if the
596 PermitLocalCommand option is enabled in ssh_config(5). Basic
597 help is available, using the -h option.
598
599 ~R Request rekeying of the connection (only useful if the peer
600 supports it).
601
602 ~V Decrease the verbosity (LogLevel) when errors are being written
603 to stderr.
604
605 ~v Increase the verbosity (LogLevel) when errors are being written
606 to stderr.
607
608TCP FORWARDING
609 Forwarding of arbitrary TCP connections over a secure channel can be
610 specified either on the command line or in a configuration file. One
611 possible application of TCP forwarding is a secure connection to a mail
612 server; another is going through firewalls.
613
614 In the example below, we look at encrypting communication for an IRC
615 client, even though the IRC server it connects to does not directly
616 support encrypted communication. This works as follows: the user
617 connects to the remote host using ssh, specifying the ports to be used to
618 forward the connection. After that it is possible to start the program
619 locally, and ssh will encrypt and forward the connection to the remote
620 server.
621
622 The following example tunnels an IRC session from the client to an IRC
623 server at M-bM-^@M-^\server.example.comM-bM-^@M-^], joining channel M-bM-^@M-^\#usersM-bM-^@M-^], nickname
624 M-bM-^@M-^\pinkyM-bM-^@M-^], using the standard IRC port, 6667:
625
626 $ ssh -f -L 6667:localhost:6667 server.example.com sleep 10
627 $ irc -c '#users' pinky IRC/127.0.0.1
628
629 The -f option backgrounds ssh and the remote command M-bM-^@M-^\sleep 10M-bM-^@M-^] is
630 specified to allow an amount of time (10 seconds, in the example) to
631 start the program which is going to use the tunnel. If no connections
632 are made within the time specified, ssh will exit.
633
634X11 FORWARDING
635 If the ForwardX11 variable is set to M-bM-^@M-^\yesM-bM-^@M-^] (or see the description of the
636 -X, -x, and -Y options above) and the user is using X11 (the DISPLAY
637 environment variable is set), the connection to the X11 display is
638 automatically forwarded to the remote side in such a way that any X11
639 programs started from the shell (or command) will go through the
640 encrypted channel, and the connection to the real X server will be made
641 from the local machine. The user should not manually set DISPLAY.
642 Forwarding of X11 connections can be configured on the command line or in
643 configuration files.
644
645 The DISPLAY value set by ssh will point to the server machine, but with a
646 display number greater than zero. This is normal, and happens because
647 ssh creates a M-bM-^@M-^\proxyM-bM-^@M-^] X server on the server machine for forwarding the
648 connections over the encrypted channel.
649
650 ssh will also automatically set up Xauthority data on the server machine.
651 For this purpose, it will generate a random authorization cookie, store
652 it in Xauthority on the server, and verify that any forwarded connections
653 carry this cookie and replace it by the real cookie when the connection
654 is opened. The real authentication cookie is never sent to the server
655 machine (and no cookies are sent in the plain).
656
657 If the ForwardAgent variable is set to M-bM-^@M-^\yesM-bM-^@M-^] (or see the description of
658 the -A and -a options above) and the user is using an authentication
659 agent, the connection to the agent is automatically forwarded to the
660 remote side.
661
662VERIFYING HOST KEYS
663 When connecting to a server for the first time, a fingerprint of the
664 server's public key is presented to the user (unless the option
665 StrictHostKeyChecking has been disabled). Fingerprints can be determined
666 using ssh-keygen(1):
667
668 $ ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
669
670 If the fingerprint is already known, it can be matched and the key can be
671 accepted or rejected. If only legacy (MD5) fingerprints for the server
672 are available, the ssh-keygen(1) -E option may be used to downgrade the
673 fingerprint algorithm to match.
674
675 Because of the difficulty of comparing host keys just by looking at
676 fingerprint strings, there is also support to compare host keys visually,
677 using random art. By setting the VisualHostKey option to M-bM-^@M-^\yesM-bM-^@M-^], a small
678 ASCII graphic gets displayed on every login to a server, no matter if the
679 session itself is interactive or not. By learning the pattern a known
680 server produces, a user can easily find out that the host key has changed
681 when a completely different pattern is displayed. Because these patterns
682 are not unambiguous however, a pattern that looks similar to the pattern
683 remembered only gives a good probability that the host key is the same,
684 not guaranteed proof.
685
686 To get a listing of the fingerprints along with their random art for all
687 known hosts, the following command line can be used:
688
689 $ ssh-keygen -lv -f ~/.ssh/known_hosts
690
691 If the fingerprint is unknown, an alternative method of verification is
692 available: SSH fingerprints verified by DNS. An additional resource
693 record (RR), SSHFP, is added to a zonefile and the connecting client is
694 able to match the fingerprint with that of the key presented.
695
696 In this example, we are connecting a client to a server,
697 M-bM-^@M-^\host.example.comM-bM-^@M-^]. The SSHFP resource records should first be added to
698 the zonefile for host.example.com:
699
700 $ ssh-keygen -r host.example.com.
701
702 The output lines will have to be added to the zonefile. To check that
703 the zone is answering fingerprint queries:
704
705 $ dig -t SSHFP host.example.com
706
707 Finally the client connects:
708
709 $ ssh -o "VerifyHostKeyDNS ask" host.example.com
710 [...]
711 Matching host key fingerprint found in DNS.
712 Are you sure you want to continue connecting (yes/no)?
713
714 See the VerifyHostKeyDNS option in ssh_config(5) for more information.
715
716SSH-BASED VIRTUAL PRIVATE NETWORKS
717 ssh contains support for Virtual Private Network (VPN) tunnelling using
718 the tun(4) network pseudo-device, allowing two networks to be joined
719 securely. The sshd_config(5) configuration option PermitTunnel controls
720 whether the server supports this, and at what level (layer 2 or 3
721 traffic).
722
723 The following example would connect client network 10.0.50.0/24 with
724 remote network 10.0.99.0/24 using a point-to-point connection from
725 10.1.1.1 to 10.1.1.2, provided that the SSH server running on the gateway
726 to the remote network, at 192.168.1.15, allows it.
727
728 On the client:
729
730 # ssh -f -w 0:1 192.168.1.15 true
731 # ifconfig tun0 10.1.1.1 10.1.1.2 netmask 255.255.255.252
732 # route add 10.0.99.0/24 10.1.1.2
733
734 On the server:
735
736 # ifconfig tun1 10.1.1.2 10.1.1.1 netmask 255.255.255.252
737 # route add 10.0.50.0/24 10.1.1.1
738
739 Client access may be more finely tuned via the /root/.ssh/authorized_keys
740 file (see below) and the PermitRootLogin server option. The following
741 entry would permit connections on tun(4) device 1 from user M-bM-^@M-^\janeM-bM-^@M-^] and on
742 tun device 2 from user M-bM-^@M-^\johnM-bM-^@M-^], if PermitRootLogin is set to
743 M-bM-^@M-^\forced-commands-onlyM-bM-^@M-^]:
744
745 tunnel="1",command="sh /etc/netstart tun1" ssh-rsa ... jane
746 tunnel="2",command="sh /etc/netstart tun2" ssh-rsa ... john
747
748 Since an SSH-based setup entails a fair amount of overhead, it may be
749 more suited to temporary setups, such as for wireless VPNs. More
750 permanent VPNs are better provided by tools such as ipsecctl(8) and
751 isakmpd(8).
752
753ENVIRONMENT
754 ssh will normally set the following environment variables:
755
756 DISPLAY The DISPLAY variable indicates the location of the
757 X11 server. It is automatically set by ssh to
758 point to a value of the form M-bM-^@M-^\hostname:nM-bM-^@M-^], where
759 M-bM-^@M-^\hostnameM-bM-^@M-^] indicates the host where the shell runs,
760 and M-bM-^@M-^XnM-bM-^@M-^Y is an integer M-bM-^IM-% 1. ssh uses this special
761 value to forward X11 connections over the secure
762 channel. The user should normally not set DISPLAY
763 explicitly, as that will render the X11 connection
764 insecure (and will require the user to manually
765 copy any required authorization cookies).
766
767 HOME Set to the path of the user's home directory.
768
769 LOGNAME Synonym for USER; set for compatibility with
770 systems that use this variable.
771
772 MAIL Set to the path of the user's mailbox.
773
774 PATH Set to the default PATH, as specified when
775 compiling ssh.
776
777 SSH_ASKPASS If ssh needs a passphrase, it will read the
778 passphrase from the current terminal if it was run
779 from a terminal. If ssh does not have a terminal
780 associated with it but DISPLAY and SSH_ASKPASS are
781 set, it will execute the program specified by
782 SSH_ASKPASS and open an X11 window to read the
783 passphrase. This is particularly useful when
784 calling ssh from a .xsession or related script.
785 (Note that on some machines it may be necessary to
786 redirect the input from /dev/null to make this
787 work.)
788
789 SSH_AUTH_SOCK Identifies the path of a UNIX-domain socket used to
790 communicate with the agent.
791
792 SSH_CONNECTION Identifies the client and server ends of the
793 connection. The variable contains four space-
794 separated values: client IP address, client port
795 number, server IP address, and server port number.
796
797 SSH_ORIGINAL_COMMAND This variable contains the original command line if
798 a forced command is executed. It can be used to
799 extract the original arguments.
800
801 SSH_TTY This is set to the name of the tty (path to the
802 device) associated with the current shell or
803 command. If the current session has no tty, this
804 variable is not set.
805
806 SSH_TUNNEL Optionally set by sshd(8) to contain the interface
807 names assigned if tunnel forwarding was requested
808 by the client.
809
810 SSH_USER_AUTH Optionally set by sshd(8), this variable may
811 contain a pathname to a file that lists the
812 authentication methods successfully used when the
813 session was established, including any public keys
814 that were used.
815
816 TZ This variable is set to indicate the present time
817 zone if it was set when the daemon was started
818 (i.e. the daemon passes the value on to new
819 connections).
820
821 USER Set to the name of the user logging in.
822
823 Additionally, ssh reads ~/.ssh/environment, and adds lines of the format
824 M-bM-^@M-^\VARNAME=valueM-bM-^@M-^] to the environment if the file exists and users are
825 allowed to change their environment. For more information, see the
826 PermitUserEnvironment option in sshd_config(5).
827
828FILES
829 ~/.rhosts
830 This file is used for host-based authentication (see above). On
831 some machines this file may need to be world-readable if the
832 user's home directory is on an NFS partition, because sshd(8)
833 reads it as root. Additionally, this file must be owned by the
834 user, and must not have write permissions for anyone else. The
835 recommended permission for most machines is read/write for the
836 user, and not accessible by others.
837
838 ~/.shosts
839 This file is used in exactly the same way as .rhosts, but allows
840 host-based authentication without permitting login with
841 rlogin/rsh.
842
843 ~/.ssh/
844 This directory is the default location for all user-specific
845 configuration and authentication information. There is no
846 general requirement to keep the entire contents of this directory
847 secret, but the recommended permissions are read/write/execute
848 for the user, and not accessible by others.
849
850 ~/.ssh/authorized_keys
851 Lists the public keys (DSA, ECDSA, Ed25519, RSA) that can be used
852 for logging in as this user. The format of this file is
853 described in the sshd(8) manual page. This file is not highly
854 sensitive, but the recommended permissions are read/write for the
855 user, and not accessible by others.
856
857 ~/.ssh/config
858 This is the per-user configuration file. The file format and
859 configuration options are described in ssh_config(5). Because of
860 the potential for abuse, this file must have strict permissions:
861 read/write for the user, and not writable by others.
862
863 ~/.ssh/environment
864 Contains additional definitions for environment variables; see
865 ENVIRONMENT, above.
866
867 ~/.ssh/id_dsa
868 ~/.ssh/id_ecdsa
869 ~/.ssh/id_ecdsa_sk
870 ~/.ssh/id_ed25519
871 ~/.ssh/id_ed25519_sk
872 ~/.ssh/id_rsa
873 Contains the private key for authentication. These files contain
874 sensitive data and should be readable by the user but not
875 accessible by others (read/write/execute). ssh will simply
876 ignore a private key file if it is accessible by others. It is
877 possible to specify a passphrase when generating the key which
878 will be used to encrypt the sensitive part of this file using
879 AES-128.
880
881 ~/.ssh/id_dsa.pub
882 ~/.ssh/id_ecdsa.pub
883 ~/.ssh/id_ecdsa_sk.pub
884 ~/.ssh/id_ed25519.pub
885 ~/.ssh/id_ed25519_sk.pub
886 ~/.ssh/id_rsa.pub
887 Contains the public key for authentication. These files are not
888 sensitive and can (but need not) be readable by anyone.
889
890 ~/.ssh/known_hosts
891 Contains a list of host keys for all hosts the user has logged
892 into that are not already in the systemwide list of known host
893 keys. See sshd(8) for further details of the format of this
894 file.
895
896 ~/.ssh/rc
897 Commands in this file are executed by ssh when the user logs in,
898 just before the user's shell (or command) is started. See the
899 sshd(8) manual page for more information.
900
901 /etc/hosts.equiv
902 This file is for host-based authentication (see above). It
903 should only be writable by root.
904
905 /etc/shosts.equiv
906 This file is used in exactly the same way as hosts.equiv, but
907 allows host-based authentication without permitting login with
908 rlogin/rsh.
909
910 /etc/ssh/ssh_config
911 Systemwide configuration file. The file format and configuration
912 options are described in ssh_config(5).
913
914 /etc/ssh/ssh_host_key
915 /etc/ssh/ssh_host_dsa_key
916 /etc/ssh/ssh_host_ecdsa_key
917 /etc/ssh/ssh_host_ed25519_key
918 /etc/ssh/ssh_host_rsa_key
919 These files contain the private parts of the host keys and are
920 used for host-based authentication.
921
922 /etc/ssh/ssh_known_hosts
923 Systemwide list of known host keys. This file should be prepared
924 by the system administrator to contain the public host keys of
925 all machines in the organization. It should be world-readable.
926 See sshd(8) for further details of the format of this file.
927
928 /etc/ssh/sshrc
929 Commands in this file are executed by ssh when the user logs in,
930 just before the user's shell (or command) is started. See the
931 sshd(8) manual page for more information.
932
933EXIT STATUS
934 ssh exits with the exit status of the remote command or with 255 if an
935 error occurred.
936
937SEE ALSO
938 scp(1), sftp(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh-keyscan(1),
939 tun(4), ssh_config(5), ssh-keysign(8), sshd(8)
940
941STANDARDS
942 S. Lehtinen and C. Lonvick, The Secure Shell (SSH) Protocol Assigned
943 Numbers, RFC 4250, January 2006.
944
945 T. Ylonen and C. Lonvick, The Secure Shell (SSH) Protocol Architecture,
946 RFC 4251, January 2006.
947
948 T. Ylonen and C. Lonvick, The Secure Shell (SSH) Authentication Protocol,
949 RFC 4252, January 2006.
950
951 T. Ylonen and C. Lonvick, The Secure Shell (SSH) Transport Layer
952 Protocol, RFC 4253, January 2006.
953
954 T. Ylonen and C. Lonvick, The Secure Shell (SSH) Connection Protocol, RFC
955 4254, January 2006.
956
957 J. Schlyter and W. Griffin, Using DNS to Securely Publish Secure Shell
958 (SSH) Key Fingerprints, RFC 4255, January 2006.
959
960 F. Cusack and M. Forssen, Generic Message Exchange Authentication for the
961 Secure Shell Protocol (SSH), RFC 4256, January 2006.
962
963 J. Galbraith and P. Remaker, The Secure Shell (SSH) Session Channel Break
964 Extension, RFC 4335, January 2006.
965
966 M. Bellare, T. Kohno, and C. Namprempre, The Secure Shell (SSH) Transport
967 Layer Encryption Modes, RFC 4344, January 2006.
968
969 B. Harris, Improved Arcfour Modes for the Secure Shell (SSH) Transport
970 Layer Protocol, RFC 4345, January 2006.
971
972 M. Friedl, N. Provos, and W. Simpson, Diffie-Hellman Group Exchange for
973 the Secure Shell (SSH) Transport Layer Protocol, RFC 4419, March 2006.
974
975 J. Galbraith and R. Thayer, The Secure Shell (SSH) Public Key File
976 Format, RFC 4716, November 2006.
977
978 D. Stebila and J. Green, Elliptic Curve Algorithm Integration in the
979 Secure Shell Transport Layer, RFC 5656, December 2009.
980
981 A. Perrig and D. Song, Hash Visualization: a New Technique to improve
982 Real-World Security, 1999, International Workshop on Cryptographic
983 Techniques and E-Commerce (CrypTEC '99).
984
985AUTHORS
986 OpenSSH is a derivative of the original and free ssh 1.2.12 release by
987 Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
988 de Raadt and Dug Song removed many bugs, re-added newer features and
989 created OpenSSH. Markus Friedl contributed the support for SSH protocol
990 versions 1.5 and 2.0.
991
992OpenBSD 6.7 April 17, 2020 OpenBSD 6.7