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