1ssh(3)                     Erlang Module Definition                     ssh(3)
2
3
4

NAME

6       ssh - Main API of the ssh application
7

DESCRIPTION

9       This  is the interface module for the SSH application. The Secure Shell
10       (SSH) Protocol is a protocol for secure remote login and  other  secure
11       network  services  over  an insecure network. See ssh(6) for details of
12       supported RFCs, versions, algorithms and unicode handling.
13
14       With the SSH application it is possible to start clients  and to  start
15       daemons  (servers).
16
17       Clients  are  started with connect/2, connect/3 or connect/4. They open
18       an encrypted connection on top of TCP/IP. In that encrypted  connection
19       one  or more channels could be opened with ssh_connection:session_chan‐
20       nel/2,4.
21
22       Each channel is an isolated "pipe" between a client-side process and  a
23       server-side  process. Those process pairs could handle for example file
24       transfers (sftp) or remote command execution (shell, exec and/or  cli).
25       If  a custom shell is implemented, the user of the client could execute
26       the special commands remotely. Note that the user is not necessarily  a
27       human but probably a system interfacing the SSH app.
28
29       A  server-side  subssystem  (channel) server is requested by the client
30       with ssh_connection:subsystem/4.
31
32       A server (daemon) is started with daemon/1, daemon/2 or daemon/3.  Pos‐
33       sible channel handlers (subsystems) are declared with the subsystem op‐
34       tion when the daemon is started.
35
36       To just run a shell on a remote machine, there are functions that  bun‐
37       dles  the  needed three steps needed into one: shell/1,2,3. Similarily,
38       to just open an sftp (file transfer) connection to  a  remote  machine,
39       the simplest way is to use ssh_sftp:start_channel/1,2,3.
40
41       To   write   your   own  client  channel  handler,  use  the  behaviour
42       ssh_client_channel. For server channel handlers use  ssh_server_channel
43       behaviour (replaces ssh_daemon_channel).
44
45       Both clients and daemons accepts options that controls the exact behav‐
46       iour. Some options are common to both. The three sets are called Client
47       Options, Daemon Options and Common Options.
48
49       The  descriptions of the options uses the Erlang Type Language with ex‐
50       plaining text.
51
52   Note:
53       The User's Guide has examples and a Getting Started section.
54
55

KEYS AND FILES

57       A number of objects must be present for the SSH  application  to  work.
58       Those objects are per default stored in files. The default names, paths
59       and file formats are the same as for OpenSSH. Keys could  be  generated
60       with the ssh-keygen program from OpenSSH. See the User's Guide.
61
62       The paths could easily be changed by options: user_dir and system_dir.
63
64       A  completly different storage could be interfaced by writing call-back
65       modules    using    the    behaviours     ssh_client_key_api     and/or
66       ssh_server_key_api.  A  callback  module  is  installed with the option
67       key_cb to the client and/or the daemon.
68
69   Daemons
70       The keys are by default stored in files:
71
72         * Mandatory: one or more Host key(s) , both private and  public.  De‐
73           fault is to store them in the directory /etc/ssh in the files
74
75           * ssh_host_dsa_key and ssh_host_dsa_key.pub
76
77           * ssh_host_rsa_key and ssh_host_rsa_key.pub
78
79           * ssh_host_ecdsa_key and ssh_host_ecdsa_key.pub
80
81           The  host  keys  directory  could  be  changed with the option sys‐
82           tem_dir.
83
84         * Optional: one or more User's public key  in case of  publickey  au‐
85           thorization.  Default  is  to  store  them concatenated in the file
86           .ssh/authorized_keys in the user's home directory.
87
88           The user keys directory could be changed with the option user_dir.
89
90   Clients
91       The keys and some other data are by default stored in files in the  di‐
92       rectory .ssh in the user's home directory.
93
94       The directory could be changed with the option user_dir.
95
96         * Optional:  a  list  of Host public key(s)  for previously connected
97           hosts. This list is handled by the SSH application without any need
98           of  user  assistance.  The  default  is  to  store them in the file
99           known_hosts.
100
101           The host_accepting_client_options() are associated with  this  list
102           of keys.
103
104         * Optional:  one  or more User's private key(s)  in case of publickey
105           authorization. The default files are
106
107           * id_dsa and id_dsa.pub
108
109           * id_rsa and id_rsa.pub
110
111           * id_ecdsa and id_ecdsa.pub
112

DATA TYPES

114   Client Options
115       client_options() = [client_option()]
116
117       client_option() =
118           ssh_file:pubkey_passphrase_client_options() |
119           host_accepting_client_options() |
120           authentication_client_options() |
121           diffie_hellman_group_exchange_client_option() |
122           connect_timeout_client_option() |
123           recv_ext_info_client_option() |
124           opaque_client_options() |
125           gen_tcp:connect_option() |
126           common_option()
127
128              Options for clients. The  individual  options  are  further  ex‐
129              plained below or by following the hyperlinks.
130
131              Note  that  not  every gen_tcp:connect_option() is accepted. See
132              set_sock_opts/2 for a list of prohibited options.
133
134              Also note that setting a gen_tcp:connect_option()  could  change
135              the socket in a way that impacts the ssh client's behaviour neg‐
136              atively. You use it on your own risk.
137
138       host_accepting_client_options() =
139           {silently_accept_hosts, accept_hosts()} |
140           {user_interaction, boolean()} |
141           {save_accepted_host, boolean()} |
142           {quiet_mode, boolean()}
143
144       accept_hosts() =
145           boolean() |
146           accept_callback() |
147           {HashAlgoSpec :: fp_digest_alg(), accept_callback()}
148
149       fp_digest_alg() = md5 | crypto:sha1() | crypto:sha2()
150
151       accept_callback() =
152           fun((PeerName :: string(), fingerprint()) -> boolean()) |
153           fun((PeerName :: string(),
154                Port :: inet:port_number(),
155                fingerprint()) ->
156                   boolean())
157
158       fingerprint() = string() | [string()]
159
160                silently_accept_hosts:
161                  This option guides the connect function on how to  act  when
162                  the connected server presents a Host Key that the client has
163                  not seen before. The default is to ask the user with a ques‐
164                  tion  on  stdio  of whether to accept or reject the new Host
165                  Key. See the option user_dir for specifying the path to  the
166                  file  known_hosts  where  previously  accepted Host Keys are
167                  recorded. See also the option key_cb for the general way  to
168                  handle keys.
169
170                  The  option  can  be  given in three different forms as seen
171                  above:
172
173                  * The value is a boolean(). The value  true  will  make  the
174                    client accept any unknown Host Key without any user inter‐
175                    action. The value false preserves the default behaviour of
176                    asking the user on stdio.
177
178                  * An accept_callback() will be called and the boolean return
179                    value true will make the client accept the Host Key. A re‐
180                    turn  value  of  false  will make the client to reject the
181                    Host Key and as a result the connection  will  be  closed.
182                    The arguments to the fun are:
183
184                    * PeerName  - a string with the name or address of the re‐
185                      mote host.
186
187                    * FingerPrint  -  the  fingerprint  of  the  Host  Key  as
188                      hostkey_fingerprint/1 calculates it.
189
190                  * A  tuple {HashAlgoSpec, accept_callback}. The HashAlgoSpec
191                    specifies which hash algorithm shall be used to  calculate
192                    the fingerprint used in the call of the accept_callback().
193                    The HashALgoSpec is either an atom or a list of  atoms  as
194                    the  first  argument  in hostkey_fingerprint/2. If it is a
195                    list of hash algorithm names, the FingerPrint argument  in
196                    the  accept_callback()  will  be a list of fingerprints in
197                    the same order as the corresponding name in the  HashAlgo‐
198                    Spec list.
199
200                user_interaction:
201                  If  false,  disables  the client to connect to the server if
202                  any user interaction is needed, such as accepting the server
203                  to  be  added  to the known_hosts file, or supplying a pass‐
204                  word.
205
206                  Even if user interaction is allowed it can be suppressed  by
207                  other  options,  such as silently_accept_hosts and password.
208                  However, those options are not always desirable to use  from
209                  a security point of view.
210
211                  Defaults to true.
212
213                save_accepted_host:
214                  If  true, the client saves an accepted host key to avoid the
215                  accept question the next time the same host is connected. If
216                  the  option  key_cb  is not present, the key is saved in the
217                  file "known_hosts". See option user_dir for the location  of
218                  that file.
219
220                  If false, the key is not saved and the key will still be un‐
221                  known at the next access of the same host.
222
223                  Defaults to true
224
225                quiet_mode:
226                  If true, the client does not print  anything  on  authoriza‐
227                  tion.
228
229                  Defaults to false
230
231       authentication_client_options() =
232           {user, string()} | {password, string()}
233
234                user:
235                  Provides  the  username.  If  this  option is not given, ssh
236                  reads from the environment (LOGNAME or USER on  UNIX,  USER‐
237                  NAME on Windows).
238
239                password:
240                  Provides a password for password authentication. If this op‐
241                  tion is not given, the user is asked for a password, if  the
242                  password authentication method is attempted.
243
244       diffie_hellman_group_exchange_client_option() =
245           {dh_gex_limits,
246            {Min :: integer() >= 1,
247             I :: integer() >= 1,
248             Max :: integer() >= 1}}
249
250              Sets  the  three  diffie-hellman-group-exchange  parameters that
251              guides the connected server in choosing a group.  See  RFC  4419
252              for the details. The default value is {1024, 6144, 8192}.
253
254       connect_timeout_client_option() = {connect_timeout, timeout()}
255
256              Sets  a timeout on the transport layer connect time. For gen_tcp
257              the time is in milli-seconds and the default value is infinity.
258
259              See the parameter Timeout in connect/4 for a timeout of the  ne‐
260              gotiation phase.
261
262       recv_ext_info_client_option() = {recv_ext_info, boolean()}
263
264              Make  the  client tell the server that the client accepts exten‐
265              sion negotiation, that is, include  ext-info-c  in  the  kexinit
266              message  sent. See RFC 8308 for details and ssh(6) for a list of
267              currently implemented extensions.
268
269              Default value is true which is compatible with other implementa‐
270              tions not supporting ext-info.
271
272   Daemon Options (Server Options)
273       daemon_options() = [daemon_option()]
274
275       daemon_option() =
276           subsystem_daemon_option() |
277           shell_daemon_option() |
278           exec_daemon_option() |
279           ssh_cli_daemon_option() |
280           tcpip_tunnel_out_daemon_option() |
281           tcpip_tunnel_in_daemon_option() |
282           authentication_daemon_options() |
283           diffie_hellman_group_exchange_daemon_option() |
284           negotiation_timeout_daemon_option() |
285           hello_timeout_daemon_option() |
286           hardening_daemon_options() |
287           callbacks_daemon_options() |
288           send_ext_info_daemon_option() |
289           opaque_daemon_options() |
290           gen_tcp:listen_option() |
291           common_option()
292
293              Options  for  daemons.  The  individual  options are further ex‐
294              plained below or by following the hyperlinks.
295
296              Note that not every  gen_tcp:listen_option()  is  accepted.  See
297              set_sock_opts/2 for a list of prohibited options.
298
299              Also  note  that  setting a gen_tcp:listen_option() could change
300              the socket in a way that impacts the ssh deamon's behaviour neg‐
301              atively. You use it on your own risk.
302
303       subsystem_daemon_option() = {subsystems, subsystem_specs()}
304
305       subsystem_specs() = [subsystem_spec()]
306
307       subsystem_spec() = {Name :: string(), mod_args()}
308
309              Defines a subsystem in the daemon.
310
311              The  subsystem_name  is the name that a client requests to start
312              with for example ssh_connection:subsystem/4.
313
314              The  channel_callback  is  the  module   that   implements   the
315              ssh_server_channel  (replaces  ssh_daemon_channel)  behaviour in
316              the daemon. See the section Creating a Subsystem in  the  User's
317              Guide for more information and an example.
318
319              If   the   subsystems  option  is  not  present,  the  value  of
320              ssh_sftpd:subsystem_spec([]) is used. This enables the sftp sub‐
321              system  by  default.  The option can be set to the empty list if
322              you do not want the daemon to run any subsystems.
323
324       shell_daemon_option() = {shell, shell_spec()}
325
326       shell_spec() = mod_fun_args() | shell_fun() | disabled
327
328       shell_fun() = 'shell_fun/1'() | 'shell_fun/2'()
329
330       'shell_fun/1'() = fun((User :: string()) -> pid())
331
332       'shell_fun/2'() =
333           fun((User :: string(), PeerAddr :: inet:ip_address()) -> pid())
334
335              Defines the read-eval-print loop used in a daemon when  a  shell
336              is  requested  by  the  client. The default is to use the Erlang
337              shell: {shell, start, []}
338
339              See the option exec-option for a description of how  the  daemon
340              executes  shell-requests  and  exec-requests  depending  on  the
341              shell- and exec-options.
342
343       exec_daemon_option() = {exec, exec_spec()}
344
345       exec_spec() =
346           {direct, exec_fun()} | disabled | deprecated_exec_opt()
347
348       exec_fun() = 'exec_fun/1'() | 'exec_fun/2'() | 'exec_fun/3'()
349
350       'exec_fun/1'() = fun((Cmd :: string()) -> exec_result())
351
352       'exec_fun/2'() =
353           fun((Cmd :: string(), User :: string()) -> exec_result())
354
355       'exec_fun/3'() =
356           fun((Cmd :: string(),
357                User :: string(),
358                ClientAddr :: ip_port()) ->
359                   exec_result())
360
361       exec_result() =
362           {ok, Result :: term()} | {error, Reason :: term()}
363
364              This option changes how the daemon executes  exec-requests  from
365              clients.  The  term in the return value is formatted to a string
366              if it is a non-string type. No trailing newline is added in  the
367              ok-case.
368
369              See the User's Guide section on One-Time Execution for examples.
370
371              Error  texts  are  returned  on  channel-type 1 which usually is
372              piped to stderr on e.g Linux systems. Texts  from  a  successful
373              execution  are  returned  on  channel-type 0 and will in similar
374              manner be piped to stdout. The exit-status code is set to 0  for
375              success  and  255 for errors. The exact results presented on the
376              client side depends on the client  and  the  client's  operating
377              system.
378
379              In case of the {direct, exec_fun()} variant or no exec-option at
380              all, all reads from standard_input will  be  from  the  received
381              data-events  of type 0. Those are sent by the client. Similarily
382              all writes to standard_output will be sent as data-events to the
383              client.  An  OS  shell client like the command 'ssh' will usally
384              use stdin and stdout for the user interface.
385
386              The option cooperates with the daemon-option shell in  the  fol‐
387              lowing way:
388
389                1.   If  neither  the  exec-option  nor  the  shell-option  is
390                present::
391                  The default Erlang evaluator is used both for exec and shell
392                  requests. The result is returned to the client.
393
394                2.  If the exec_spec's value is disabled (the shell-option may
395                or may not be present)::
396                  No exec-requests are executed but shell-requests are not af‐
397                  fected, they follow the shell_spec's value.
398
399                3.  If  the exec-option is present and the exec_spec value =/=
400                disabled (the shell-option may or may not be present)::
401                  The exec_spec fun() is called with the same number of param‐
402                  eters as the arity of the fun, and the result is returned to
403                  the client. Shell-requests are not affected, they follow the
404                  shell_spec's value.
405
406                4.  If  the  exec-option  is  absent,  and the shell-option is
407                present with the default  Erlang  shell  as  the  shell_spec's
408                value::
409                  The default Erlang evaluator is used both for exec and shell
410                  requests. The result is returned to the client.
411
412                5. If the exec-option  is  absent,  and  the  shell-option  is
413                present  with a value that is neither the default Erlang shell
414                nor the value disabled::
415                  The exec-request is not evaluated and an  error  message  is
416                  returned  to the client. Shell-requests are executed accord‐
417                  ing to the value of the shell_spec.
418
419                6. If the exec-option is absent, and the shell_spec's value is
420                disabled::
421                  Exec  requests are executed by the default shell, but shell-
422                  requests are not executed.
423
424              If a custom CLI is installed (see the option ssh_cli) the  rules
425              above are replaced by thoose implied by the custom CLI.
426
427          Note:
428              The  exec-option  has existed for a long time but has not previ‐
429              ously been documented. The old definition and behaviour are  re‐
430              tained  but obey the rules 1-6 above if conflicting. The old and
431              undocumented style should not be used in new programs.
432
433
434       deprecated_exec_opt() = function() | mod_fun_args()
435
436              Old-style exec specification that are  kept  for  compatibility,
437              but should not be used in new programs
438
439       ssh_cli_daemon_option() = {ssh_cli, mod_args() | no_cli}
440
441              Provides your own CLI implementation in a daemon.
442
443              It is a channel callback module that implements a shell and com‐
444              mand execution. The shell's read-eval-print loop can be  custom‐
445              ized,  using  the option shell. This means less work than imple‐
446              menting an own CLI channel. If ssh_cli is set to no_cli, the CLI
447              channels  like  shell  and  exec are disabled and only subsystem
448              channels are allowed.
449
450       authentication_daemon_options() =
451           ssh_file:system_dir_daemon_option() |
452           {auth_method_kb_interactive_data, prompt_texts()} |
453           {user_passwords, [{UserName :: string(), Pwd :: string()}]} |
454           {pk_check_user, boolean()} |
455           {password, string()} |
456           {pwdfun, pwdfun_2() | pwdfun_4()}
457
458       prompt_texts() =
459           kb_int_tuple() | kb_int_fun_3() | kb_int_fun_4()
460
461       kb_int_tuple() =
462           {Name :: string(),
463            Instruction :: string(),
464            Prompt :: string(),
465            Echo :: boolean()}
466
467       kb_int_fun_3() =
468           fun((Peer :: ip_port(), User :: string(), Service :: string()) ->
469                   kb_int_tuple())
470
471       kb_int_fun_4() =
472           fun((Peer :: ip_port(),
473                User :: string(),
474                Service :: string(),
475                State :: any()) ->
476                   kb_int_tuple())
477
478       pwdfun_2() =
479           fun((User :: string(), Password :: string() | pubkey) ->
480                   boolean())
481
482       pwdfun_4() =
483           fun((User :: string(),
484                Password :: string() | pubkey,
485                PeerAddress :: ip_port(),
486                State :: any()) ->
487                   boolean() |
488                   disconnect |
489                   {boolean(), NewState :: any()})
490
491                auth_method_kb_interactive_data:
492                  Sets the text strings that the daemon sends  to  the  client
493                  for presentation to the user when using keyboard-interactive
494                  authentication.
495
496                  If the fun/3 or fun/4 is used, it is called when the  actual
497                  authentication  occurs and may therefore return dynamic data
498                  like time, remote ip etc.
499
500                  The parameter Echo guides the client about need to hide  the
501                  password.
502
503                  The   default  value  is:  {auth_method_kb_interactive_data,
504                  {"SSH server", "Enter password for  \""++User++"\"",  "pass‐
505                  word: ", false}>
506
507                user_passwords:
508                  Provides  passwords  for  password authentication. The pass‐
509                  words are used when someone tries to connect to  the  server
510                  and  public  key  user-authentication fails. The option pro‐
511                  vides a list of valid usernames and the corresponding  pass‐
512                  words.
513
514            Warning:
515                Note  that  this  is very insecure due to the plain-text pass‐
516                words; it is intended for test purposes. Use the pwdfun option
517                to handle the password checking instead.
518
519
520                pk_check_user:
521                  Enables  checking  of  the  client's user name in the server
522                  when doing public key authentication. It is disabled by  de‐
523                  fault.
524
525                  The  term  "user"  is used differently in OpenSSH and SSH in
526                  Erlang/OTP: see more in the User's Guide.
527
528                  If the option is enabled, and no pwdfun is present, the user
529                  name  must  present  in  the user_passwords for the check to
530                  succeed but the value of the password is not checked.
531
532                  In case of a pwdfun checking the user, the  atom  pubkey  is
533                  put in the password argument.
534
535                password:
536                  Provides a global password that authenticates any user.
537
538            Warning:
539                Intended to facilitate testing.
540
541                From  a security perspective this option makes the server very
542                vulnerable.
543
544
545                pwdfun with pwdfun_4():
546                  Provides a function for password validation. This could used
547                  for calling an external system or handeling passwords stored
548                  as hash values.
549
550                  This fun can also be used to make delays  in  authentication
551                  tries for example by calling timer:sleep/1.
552
553                  To  facilitate  for  instance  counting of failed tries, the
554                  State variable could be used. This state is  per  connection
555                  only.  The first time the pwdfun is called for a connection,
556                  the State variable has the value undefined.
557
558                  The fun should return:
559
560                  * true if the user and password is valid
561
562                  * false if the user or password is invalid
563
564                  * disconnect if a SSH_MSG_DISCONNECT message should be  sent
565                    immediately.  It will be followed by a close of the under‐
566                    lying tcp connection.
567
568                  * {true, NewState:any()} if the user and password is valid
569
570                  * {false, NewState:any()} if the user or password is invalid
571
572                  A third usage is to block login attempts from a missbehaving
573                  peer.  The  State  described above can be used for this. The
574                  return value disconnect is useful for this.
575
576                  In case of the pk_check_user is set, the atom pubkey is  put
577                  in the password argument when validating a public key login.
578                  The pwdfun is then responsible to check that the  user  name
579                  is valid.
580
581                pwdfun with pwdfun_2():
582                  Provides  a  function for password validation. This function
583                  is called with user and password as strings, and returns:
584
585                  * true if the user and password is valid
586
587                  * false if the user or password is invalid
588
589                  In case of the pk_check_user is set, the atom pubkey is  put
590                  in the password argument when validating a public key login.
591                  The pwdfun is then responsible to check that the  user  name
592                  is valid.
593
594                  This variant is kept for compatibility.
595
596       diffie_hellman_group_exchange_daemon_option() =
597           {dh_gex_groups,
598            [explicit_group()] |
599            explicit_group_file() |
600            ssh_moduli_file()} |
601           {dh_gex_limits, {Min :: integer() >= 1, Max :: integer() >= 1}}
602
603       explicit_group() =
604           {Size :: integer() >= 1,
605            G :: integer() >= 1,
606            P :: integer() >= 1}
607
608       explicit_group_file() = {file, string()}
609
610       ssh_moduli_file() = {ssh_moduli_file, string()}
611
612                dh_gex_groups:
613                  Defines  the groups the server may choose among when diffie-
614                  hellman-group-exchange is negotiated. See RFC 4419  for  de‐
615                  tails. The three variants of this option are:
616
617                  {Size=integer(),G=integer(),P=integer()}:
618                    The groups are given explicitly in this list. There may be
619                    several elements with the same Size. In such a  case,  the
620                    server will choose one randomly in the negotiated Size.
621
622                  {file,filename()}:
623                    The  file  must  have one or more three-tuples {Size=inte‐
624                    ger(),G=integer(),P=integer()} terminated by  a  dot.  The
625                    file is read when the daemon starts.
626
627                  {ssh_moduli_file,filename()}:
628                    The  file  must  be  in ssh-keygen moduli file format. The
629                    file is read when the daemon starts.
630
631                  The default list is fetched from the public_key application.
632
633                dh_gex_limits:
634                  Limits what a client can ask for in diffie-hellman-group-ex‐
635                  change.  The  limits  will be {MaxUsed = min(MaxClient,Max),
636                  MinUsed = max(MinClient,Min)} where MaxClient and  MinClient
637                  are the values proposed by a connecting client.
638
639                  The default value is {0,infinity}.
640
641                  If  MaxUsed < MinUsed in a key exchange, it will fail with a
642                  disconnect.
643
644                  See RFC 4419 for the function of the Max and Min values.
645
646       hello_timeout_daemon_option() = {hello_timeout, timeout()}
647
648              Maximum time in milliseconds for the first part of the ssh  ses‐
649              sion setup, the hello message exchange. Defaults to 30000 ms (30
650              seconds). If the client fails to send the first  message  within
651              this time, the connection is closed.
652
653       negotiation_timeout_daemon_option() =
654           {negotiation_timeout, timeout()}
655
656              Maximum time in milliseconds for the authentication negotiation.
657              Defaults to 120000 ms (2 minutes). If the client fails to log in
658              within this time, the connection is closed.
659
660       hardening_daemon_options() =
661           {max_sessions, integer() >= 1} |
662           {max_channels, integer() >= 1} |
663           {parallel_login, boolean()} |
664           {minimal_remote_max_packet_size, integer() >= 1}
665
666                max_sessions:
667                  The  maximum  number  of  simultaneous sessions that are ac‐
668                  cepted at any time for this daemon. This  includes  sessions
669                  that  are being authorized. Thus, if set to N, and N clients
670                  have connected but not started the login process, connection
671                  attempt  N+1  is aborted. If N connections are authenticated
672                  and still logged in, no more logins are accepted  until  one
673                  of the existing ones log out.
674
675                  The  counter is per listening port. Thus, if two daemons are
676                  started,  one  with  {max_sessions,N}  and  the  other  with
677                  {max_sessions,M},  in total N+M connections are accepted for
678                  the whole ssh application.
679
680                  Notice that if parallel_login is false, only one client at a
681                  time can be in the authentication phase.
682
683                  By default, this option is not set. This means that the num‐
684                  ber is not limited.
685
686                max_channels:
687                  The maximum number of channels with active remote  subsystem
688                  that are accepted for each connection to this daemon
689
690                  By default, this option is not set. This means that the num‐
691                  ber is not limited.
692
693                parallel_login:
694                  If set to false (the default value), only one login is  han‐
695                  dled at a time. If set to true, an unlimited number of login
696                  attempts are allowed simultaneously.
697
698                  If the max_sessions option is set to N and parallel_login is
699                  set  to  true,  the maximum number of simultaneous login at‐
700                  tempts at any time is limited to N-K, where K is the  number
701                  of authenticated connections present at this daemon.
702
703            Warning:
704                Do not enable parallel_logins without protecting the server by
705                other means, for example, by  the  max_sessions  option  or  a
706                firewall configuration. If set to true, there is no protection
707                against DOS attacks.
708
709
710                minimal_remote_max_packet_size:
711                  The least maximum packet size that the daemon will accept in
712                  channel  open requests from the client. The default value is
713                  0.
714
715       callbacks_daemon_options() =
716           {failfun,
717            fun((User :: string(),
718                 PeerAddress :: inet:ip_address(),
719                 Reason :: term()) ->
720                    term())} |
721           {connectfun,
722            fun((User :: string(),
723                 PeerAddress :: inet:ip_address(),
724                 Method :: string()) ->
725                    term())}
726
727                connectfun:
728                  Provides a fun to implement your own logging when a user au‐
729                  thenticates to the server.
730
731                failfun:
732                  Provides  a  fun  to  implement your own logging when a user
733                  fails to authenticate.
734
735       send_ext_info_daemon_option() = {send_ext_info, boolean()}
736
737              Make the server (daemon) tell the client that the server accepts
738              extension  negotiation,  that is, include ext-info-s in the kex‐
739              init message sent. See RFC 8308 for details  and  ssh(6)  for  a
740              list of currently implemented extensions.
741
742              Default value is true which is compatible with other implementa‐
743              tions not supporting ext-info.
744
745       tcpip_tunnel_in_daemon_option() = {tcpip_tunnel_in, boolean()}
746
747              Enables (true) or disables (false) the possibility to  tunnel  a
748              TCP/IP connection in to a server. Disabled per default.
749
750       tcpip_tunnel_out_daemon_option() =
751           {tcpip_tunnel_out, boolean()}
752
753              Enables  (true)  or disables (false) the possibility to tunnel a
754              TCP/IP connection out of a server. Disabled per default.
755
756   Options common to clients and daemons
757       common_options() = [common_option()]
758
759       common_option() =
760           ssh_file:user_dir_common_option() |
761           profile_common_option() |
762           max_idle_time_common_option() |
763           key_cb_common_option() |
764           disconnectfun_common_option() |
765           unexpectedfun_common_option() |
766           ssh_msg_debug_fun_common_option() |
767           rekey_limit_common_option() |
768           id_string_common_option() |
769           pref_public_key_algs_common_option() |
770           preferred_algorithms_common_option() |
771           modify_algorithms_common_option() |
772           auth_methods_common_option() |
773           inet_common_option() |
774           fd_common_option()
775
776              The options above can be used both in  clients  and  in  daemons
777              (servers). They are further explained below.
778
779       profile_common_option() = {profile, atom()}
780
781              Used  together  with  ip-address and port to uniquely identify a
782              ssh daemon. This can be useful  in  a  virtualized  environment,
783              where there can be more that one server that has the same ip-ad‐
784              dress and port. If this property is not explicitly  set,  it  is
785              assumed that the the ip-address and port uniquely identifies the
786              SSH daemon.
787
788       max_idle_time_common_option() = {idle_time, timeout()}
789
790              Sets a time-out on a connection when no channels are  open.  De‐
791              faults to infinity. The unit is milliseconds.
792
793              The timeout is not active until channels are started, so it does
794              not limit the time from the connection  creation  to  the  first
795              channel opening.
796
797       rekey_limit_common_option() =
798           {rekey_limit,
799            Bytes ::
800                limit_bytes() |
801                {Minutes :: limit_time(), Bytes :: limit_bytes()}}
802
803       limit_bytes() = integer() >= 0 | infinity
804
805       limit_time() = integer() >= 1 | infinity
806
807              Sets  the  limit  when rekeying is to be initiated. Both the max
808              time and max amount of data could be configured:
809
810                * {Minutes, Bytes} initiate rekeying when any  of  the  limits
811                  are reached.
812
813                * Bytes  initiate  rekeying  when  Bytes  number  of bytes are
814                  transferred, or at latest after one hour.
815
816              When a rekeying is done, both the timer and the byte counter are
817              restarted. Defaults to one hour and one GByte.
818
819              If  Minutes  is set to infinity, no rekeying will ever occur due
820              to that max time has passed. Setting Bytes to infinity will  in‐
821              hibit  rekeying  after  a certain amount of data has been trans‐
822              ferred. If the option value is set to {infinity,  infinity},  no
823              rekeying  will be initiated. Note that rekeying initiated by the
824              peer will still be performed.
825
826       key_cb_common_option() =
827           {key_cb,
828            Module :: atom() | {Module :: atom(), Opts :: [term()]}}
829
830              Module  implementing  the  behaviour  ssh_client_key_api  and/or
831              ssh_server_key_api.  Can  be  used  to customize the handling of
832              public keys. If callback options are  provided  along  with  the
833              module  name, they are made available to the callback module via
834              the options passed to it under the key 'key_cb_private'.
835
836              The Opts defaults to [] when only the Module is specified.
837
838              The default value of this option is {ssh_file, []}. See also the
839              manpage of ssh_file.
840
841              A call to the call-back function F will be
842
843                     Module:F(..., [{key_cb_private,Opts}|UserOptions])
844
845
846              where  ...  are  arguments  to F as in ssh_client_key_api and/or
847              ssh_server_key_api. The UserOptions are  the  options  given  to
848              ssh:connect, ssh:shell or ssh:daemon.
849
850       pref_public_key_algs_common_option() =
851           {pref_public_key_algs, [pubkey_alg()]}
852
853              List of user (client) public key algorithms to try to use.
854
855              The  default  value is the public_key entry in the list returned
856              by ssh:default_algorithms/0.
857
858              If there is no public key of a  specified  type  available,  the
859              corresponding  entry  is ignored. Note that the available set is
860              dependent on the underlying cryptolib and current user's  public
861              keys.
862
863              See  also  the  option  user_dir  for specifying the path to the
864              user's keys.
865
866       disconnectfun_common_option() =
867           {disconnectfun, fun((Reason :: term()) -> void | any())}
868
869              Provides a fun to implement your own logging or  other  handling
870              at disconnects.
871
872       unexpectedfun_common_option() =
873           {unexpectedfun,
874            fun((Message :: term(), {Host :: term(), Port :: term()}) ->
875                    report | skip)}
876
877              Provides  a  fun  to  implement your own logging or other action
878              when an unexpected message arrives. If the  fun  returns  report
879              the  usual  info report is issued but if skip is returned no re‐
880              port is generated.
881
882       ssh_msg_debug_fun_common_option() =
883           {ssh_msg_debug_fun,
884            fun((ssh:connection_ref(),
885                 AlwaysDisplay :: boolean(),
886                 Msg :: binary(),
887                 LanguageTag :: binary()) ->
888                    any())}
889
890              Provide a fun to implement your own logging of the  SSH  message
891              SSH_MSG_DEBUG.  The  last three parameters are from the message,
892              see RFC 4253, section 11.3. The connection_ref() is  the  refer‐
893              ence  to the connection on which the message arrived. The return
894              value from the fun is not checked.
895
896              The default behaviour is ignore the message. To get  a  printout
897              for  each  message  with  AlwaysDisplay  = true, use for example
898              {ssh_msg_debug_fun, fun(_,true,M,_)->  io:format("DEBUG:  ~p~n",
899              [M]) end}
900
901       id_string_common_option() =
902           {id_string,
903            string() |
904            random |
905            {random, Nmin :: integer() >= 1, Nmax :: integer() >= 1}}
906
907              The  string  the  daemon  will present to a connecting peer ini‐
908              tially. The default value is "Erlang/VSN" where VSN is  the  ssh
909              application version number.
910
911              The  value  random  will  cause a random string to be created at
912              each connection attempt. This is to make it a bit more difficult
913              for a malicious peer to find the ssh software brand and version.
914
915              The value {random, Nmin, Nmax} will make a random string with at
916              least Nmin characters and at most Nmax characters.
917
918       preferred_algorithms_common_option() =
919           {preferred_algorithms, algs_list()}
920
921       algs_list() = [alg_entry()]
922
923       alg_entry() =
924           {kex, [kex_alg()]} |
925           {public_key, [pubkey_alg()]} |
926           {cipher, double_algs(cipher_alg())} |
927           {mac, double_algs(mac_alg())} |
928           {compression, double_algs(compression_alg())}
929
930       kex_alg() =
931           'diffie-hellman-group-exchange-sha1' |
932           'diffie-hellman-group-exchange-sha256' |
933           'diffie-hellman-group1-sha1' | 'diffie-hellman-group14-sha1' |
934           'diffie-hellman-group14-sha256' |
935           'diffie-hellman-group16-sha512' |
936           'diffie-hellman-group18-sha512' | 'curve25519-sha256' |
937           'curve25519-sha256@libssh.org' | 'curve448-sha512' |
938           'ecdh-sha2-nistp256' | 'ecdh-sha2-nistp384' |
939           'ecdh-sha2-nistp521'
940
941       pubkey_alg() =
942           'ecdsa-sha2-nistp256' | 'ecdsa-sha2-nistp384' |
943           'ecdsa-sha2-nistp521' | 'ssh-ed25519' | 'ssh-ed448' |
944           'rsa-sha2-256' | 'rsa-sha2-512' | 'ssh-dss' | 'ssh-rsa'
945
946       cipher_alg() =
947           '3des-cbc' | 'AEAD_AES_128_GCM' | 'AEAD_AES_256_GCM' |
948           'aes128-cbc' | 'aes128-ctr' | 'aes128-gcm@openssh.com' |
949           'aes192-ctr' | 'aes192-cbc' | 'aes256-cbc' | 'aes256-ctr' |
950           'aes256-gcm@openssh.com' | 'chacha20-poly1305@openssh.com'
951
952       mac_alg() =
953           'AEAD_AES_128_GCM' | 'AEAD_AES_256_GCM' | 'hmac-sha1' |
954           'hmac-sha1-etm@openssh.com' | 'hmac-sha1-96' |
955           'hmac-sha2-256' | 'hmac-sha2-512' |
956           'hmac-sha2-256-etm@openssh.com' |
957           'hmac-sha2-512-etm@openssh.com'
958
959       compression_alg() = none | zlib | 'zlib@openssh.com'
960
961       double_algs(AlgType) =
962           [{client2server, [AlgType]} | {server2client, [AlgType]}] |
963           [AlgType]
964
965              List of algorithms to use in the algorithm negotiation. The  de‐
966              fault algs_list() can be obtained from default_algorithms/0.
967
968              If  an  alg_entry()  is  missing in the algs_list(), the default
969              value is used for that entry.
970
971              Here is an example of this option:
972
973                     {preferred_algorithms,
974                     [{public_key,['ssh-rsa','ssh-dss']},
975                     {cipher,[{client2server,['aes128-ctr']},
976                        {server2client,['aes128-cbc','3des-cbc']}]},
977                     {mac,['hmac-sha2-256','hmac-sha1']},
978                     {compression,[none,zlib]}
979                     ]
980                     }
981
982
983              The example specifies different algorithms in the two directions
984              (client2server  and server2client), for cipher but specifies the
985              same algorithms for mac and compression in both directions.  The
986              kex (key exchange) is implicit but public_key is set explicitly.
987
988              For background and more examples see the User's Guide.
989
990              If an algorithm name occurs more than once in a list, the behav‐
991              iour is undefined. The tags in the property lists are  also  as‐
992              sumed to occur at most one time.
993
994          Warning:
995              Changing  the  values  can make a connection less secure. Do not
996              change unless you know exactly what you are doing. If you do not
997              understand the values then you are not supposed to change them.
998
999
1000       modify_algorithms_common_option() =
1001           {modify_algorithms, modify_algs_list()}
1002
1003       modify_algs_list() =
1004           [{append, algs_list()} |
1005            {prepend, algs_list()} |
1006            {rm, algs_list()}]
1007
1008              Modifies the list of algorithms to use in the algorithm negotia‐
1009              tion. The  modifications  are  applied  after  the  option  pre‐
1010              ferred_algorithms (if existing) is applied.
1011
1012              The algoritm for modifications works like this:
1013
1014                * Input  is  the  modify_algs_list() and a set of algorithms A
1015                  obtained from the preferred_algorithms option  if  existing,
1016                  or else from the ssh:default_algorithms/0.
1017
1018                * The head of the modify_algs_list() modifies A giving the re‐
1019                  sult A'.
1020
1021                  The possible modifications are:
1022
1023                  * Append or prepend supported but not  enabled  algorithm(s)
1024                    to  the  list  of algorithms. If the wanted algorithms al‐
1025                    ready are in A they will first be  removed  and  then  ap‐
1026                    pended or prepended,
1027
1028                  * Remove (rm) one or more algorithms from A.
1029
1030                * Repeat   the   modification  step  with  the  tail  of  mod‐
1031                  ify_algs_list() and the resulting A'.
1032
1033              If an unsupported algorithm is  in  the  modify_algs_list(),  it
1034              will be silently ignored
1035
1036              If there are more than one modify_algorithms options, the result
1037              is undefined.
1038
1039              Here is an example of this option:
1040
1041                     {modify_algorithms,
1042                     [{prepend, [{kex, ['diffie-hellman-group1-sha1']}],
1043                     {rm,      [{compression, [none]}]}
1044                     ]
1045                     }
1046
1047
1048              The example specifies that:
1049
1050                * the old key exchange algorithm  'diffie-hellman-group1-sha1'
1051                  should be the main alternative. It will be the main alterna‐
1052                  tive since it is prepened to the list
1053
1054                * The compression algorithm none (= no compression) is removed
1055                  so compression is enforced
1056
1057              For background and more examples see the User's Guide.
1058
1059       inet_common_option() = {inet, inet | inet6}
1060
1061              IP version to use when the host address is specified as any.
1062
1063       auth_methods_common_option() = {auth_methods, string()}
1064
1065              Comma-separated  string  that  determines  which  authentication
1066              methods that the client shall support and in  which  order  they
1067              are tried. Defaults to "publickey,keyboard-interactive,password"
1068
1069              Note  that  the  client  is free to use any order and to exclude
1070              methods.
1071
1072       fd_common_option() = {fd, gen_tcp:socket()}
1073
1074              Allows an existing file-descriptor to be used (passed on to  the
1075              transport protocol).
1076
1077   Other data types
1078       host() = string() | inet:ip_address() | loopback
1079
1080       ip_port() = {inet:ip_address(), inet:port_number()}
1081
1082       mod_args() = {Module :: atom(), Args :: list()}
1083
1084       mod_fun_args() =
1085           {Module :: atom(), Function :: atom(), Args :: list()}
1086
1087       open_socket() = gen_tcp:socket()
1088
1089              The  socket  is  supposed to be result of a gen_tcp:connect or a
1090              gen_tcp:accept. The socket must be in  passive  mode  (that  is,
1091              opened with the option {active,false}).
1092
1093       daemon_ref()
1094
1095              Opaque data type representing a daemon.
1096
1097              Returned by the functions daemon/1,2,3.
1098
1099       connection_ref()
1100
1101              Opaque  data type representing a connection between a client and
1102              a server (daemon).
1103
1104              Returned by the functions connect/2,3,4 and ssh_sftp:start_chan‐
1105              nel/2,3.
1106
1107       channel_id()
1108
1109              Opaque data type representing a channel inside a connection.
1110
1111              Returned by the functions ssh_connection:session_channel/2,4.
1112
1113       connection_info_tuple() =
1114           {client_version, version()} |
1115           {server_version, version()} |
1116           {user, string()} |
1117           {peer, {inet:hostname(), ip_port()}} |
1118           {sockname, ip_port()} |
1119           {options, client_options()} |
1120           {algorithms, conn_info_algs()} |
1121           {channels, conn_info_channels()}
1122
1123       version() = {protocol_version(), software_version()}
1124
1125       protocol_version() =
1126           {Major :: integer() >= 1, Minor :: integer() >= 0}
1127
1128       software_version() = string()
1129
1130       conn_info_algs() =
1131           [{kex, kex_alg()} |
1132            {hkey, pubkey_alg()} |
1133            {encrypt, cipher_alg()} |
1134            {decrypt, cipher_alg()} |
1135            {send_mac, mac_alg()} |
1136            {recv_mac, mac_alg()} |
1137            {compress, compression_alg()} |
1138            {decompress, compression_alg()} |
1139            {send_ext_info, boolean()} |
1140            {recv_ext_info, boolean()}]
1141
1142       conn_info_channels() = [proplists:proplist()]
1143
1144              Return  values  from the connection_info/1 and connection_info/2
1145              functions.
1146
1147              In the option info tuple are only the options included that dif‐
1148              fers from the default values.
1149
1150       daemon_info_tuple() =
1151           {port, inet:port_number()} |
1152           {ip, inet:ip_address()} |
1153           {profile, atom()} |
1154           {options, daemon_options()}
1155
1156              Return  values  from  the  daemon_info/1 and daemon_info/2 func‐
1157              tions.
1158
1159              In the option info tuple are only the options included that dif‐
1160              fers from the default values.
1161
1162       opaque_client_options()
1163
1164       opaque_daemon_options()
1165
1166       opaque_common_options()
1167
1168              Opaque types that define experimental options that are not to be
1169              used in products.
1170

EXPORTS

1172       close(ConnectionRef) -> ok | {error, term()}
1173
1174              Types:
1175
1176                 ConnectionRef = connection_ref()
1177
1178              Closes an SSH connection.
1179
1180       connect(Host, Port, Options) -> Result
1181       connect(Host, Port, Options, NegotiationTimeout) -> Result
1182       connect(TcpSocket, Options) -> Result
1183       connect(TcpSocket, Options, NegotiationTimeout) -> Result
1184
1185              Types:
1186
1187                 Host = host()
1188                 Port = inet:port_number()
1189                 Options = client_options()
1190                 TcpSocket = open_socket()
1191                 NegotiationTimeout = timeout()
1192                 Result = {ok, connection_ref()} | {error, term()}
1193
1194              Connects to an SSH server at the Host on Port.
1195
1196              As an alternative, an already open TCP socket could be passed to
1197              the  function  in  TcpSocket. The SSH initiation and negotiation
1198              will be initiated on that one with the SSH that should be at the
1199              other end.
1200
1201              No  channel  is  started.  This  is done by calling  ssh_connec‐
1202              tion:session_channel/[2, 4].
1203
1204              The NegotiationTimeout is in milli-seconds. The default value is
1205              infinity.  For  connection timeout, use the option connect_time‐
1206              out.
1207
1208       connection_info(ConnectionRef) -> InfoTupleList
1209
1210       connection_info(ConnectionRef, Key :: ItemList | Item) ->
1211                          InfoTupleList | InfoTuple
1212
1213              Types:
1214
1215                 ConnectionRef = connection_ref()
1216                 ItemList = [Item]
1217                 Item =
1218                     client_version | server_version | user | peer |  sockname
1219                 |
1220                     options | algorithms | sockname
1221                 InfoTupleList = [InfoTuple]
1222                 InfoTuple = connection_info_tuple()
1223
1224              Returns  information  about a connection intended for e.g debug‐
1225              ging or logging.
1226
1227              When the Key is a single Item, the result is a single InfoTuple
1228
1229       set_sock_opts(ConnectionRef, SocketOptions) ->
1230                        ok | {error, inet:posix()}
1231
1232              Types:
1233
1234                 ConnectionRef = connection_ref()
1235                 SocketOptions = [gen_tcp:option()]
1236
1237              Sets tcp socket options on the tcp-socket below an  ssh  connec‐
1238              tion.
1239
1240              This  function calls the inet:setopts/2, read that documentation
1241              and for gen_tcp:option().
1242
1243              All gen_tcp socket options except
1244
1245                * active
1246
1247                * deliver
1248
1249                * mode and
1250
1251                * packet
1252
1253              are allowed. The excluded options are reserved by the SSH appli‐
1254              cation.
1255
1256          Warning:
1257              This  is  an extremly dangerous function. You use it on your own
1258              risk.
1259
1260              Some options are OS and OS version dependent. Do not use it  un‐
1261              less you know what effect your option values will have on an TCP
1262              stream.
1263
1264              Some values may destroy the functionality of the SSH protocol.
1265
1266
1267       get_sock_opts(ConnectionRef, SocketGetOptions) ->
1268                        ok | {error, inet:posix()}
1269
1270              Types:
1271
1272                 ConnectionRef = connection_ref()
1273                 SocketGetOptions = [gen_tcp:option_name()]
1274
1275              Get tcp socket option values of the tcp-socket below an ssh con‐
1276              nection.
1277
1278              This function calls the inet:getopts/2, read that documentation.
1279
1280       daemon(Port | TcpSocket) -> Result
1281       daemon(Port | TcpSocket, Options) -> Result
1282       daemon(HostAddress, Port, Options) -> Result
1283
1284              Types:
1285
1286                 Port = integer()
1287                 TcpSocket = open_socket()
1288                 Options = daemon_options()
1289                 HostAddress = host() | any
1290                 Result = {ok, daemon_ref()} | {error, atom()}
1291
1292              Starts a server listening for SSH connections on the given port.
1293              If the Port is 0, a random  free  port  is  selected.  See  dae‐
1294              mon_info/1 about how to find the selected port number.
1295
1296              As an alternative, an already open TCP socket could be passed to
1297              the function in TcpSocket. The SSH  initiation  and  negotiation
1298              will  be  initiated  on that one when an SSH starts at the other
1299              end of the TCP socket.
1300
1301              For a description of the options, see Daemon Options.
1302
1303              Please note that by historical reasons both the HostAddress  ar‐
1304              gument  and  the  gen_tcp  connect_option() {ip,Address} set the
1305              listening address. This is a  source  of  possible  inconsistent
1306              settings.
1307
1308              The rules for handling the two address passing options are:
1309
1310                * if HostAddress is an IP-address, that IP-address is the lis‐
1311                  tening address. An 'ip'-option will be discarded if present.
1312
1313                * if HostAddress is the atom loopback, the  listening  address
1314                  is  loopback  and an loopback address will be choosen by the
1315                  underlying layers.  An  'ip'-option  will  be  discarded  if
1316                  present.
1317
1318                * if  HostAddress  is  the  atom  any  and  no  'ip'-option is
1319                  present, the listening address is any and  the  socket  will
1320                  listen to all addresses
1321
1322                * if  HostAddress  is  any  and an 'ip'-option is present, the
1323                  listening address is set to the value of the 'ip'-option
1324
1325       daemon_info(DaemonRef) ->
1326                      {ok, InfoTupleList} | {error, bad_daemon_ref}
1327
1328       daemon_info(DaemonRef, Key :: ItemList | Item) ->
1329                      InfoTupleList | InfoTuple | {error, bad_daemon_ref}
1330
1331              Types:
1332
1333                 DaemonRef = daemon_ref()
1334                 ItemList = [Item]
1335                 Item = ip | port | profile | options
1336                 InfoTupleList = [InfoTuple]
1337                 InfoTuple = daemon_info_tuple()
1338
1339              Returns information about a daemon intended for e.g debugging or
1340              logging.
1341
1342              When the Key is a single Item, the result is a single InfoTuple
1343
1344              Note  that  daemon_info/1  and  daemon_info/2  returns different
1345              types due to compatibility reasons.
1346
1347       default_algorithms() -> algs_list()
1348
1349              Returns a key-value list, where the keys are the different types
1350              of algorithms and the values are the algorithms themselves.
1351
1352              See the User's Guide for an example.
1353
1354       shell(Host | TcpSocket) -> Result
1355       shell(Host | TcpSocket, Options) -> Result
1356       shell(Host, Port, Options) -> Result
1357
1358              Types:
1359
1360                 Host = host()
1361                 TcpSocket = open_socket()
1362                 Port = inet:port_number()
1363                 Options = client_options()
1364                 Result = ok | {error, Reason::term()}
1365
1366              Connects  to an SSH server at Host and Port (defaults to 22) and
1367              starts an interactive shell on that remote host.
1368
1369              As an alternative, an already open TCP socket could be passed to
1370              the  function  in  TcpSocket. The SSH initiation and negotiation
1371              will be initiated on that one and finaly a shell will be started
1372              on the host at the other end of the TCP socket.
1373
1374              For a description of the options, see Client Options.
1375
1376              The function waits for user input, and does not return until the
1377              remote shell is ended (that is, exit from the shell).
1378
1379       start() -> ok | {error, term()}
1380
1381       start(Type) -> ok | {error, term()}
1382
1383              Types:
1384
1385                 Type = permanent | transient | temporary
1386
1387              Utility function  that  starts  the  applications  crypto,  pub‐
1388              lic_key,  and  ssh. Default type is temporary. For more informa‐
1389              tion, see the application(3) manual page in Kernel.
1390
1391       stop() -> ok | {error, term()}
1392
1393              Stops the ssh application. For more information, see the  appli‐
1394              cation(3) manual page in Kernel.
1395
1396       stop_daemon(DaemonRef :: daemon_ref()) -> ok
1397
1398       stop_daemon(Address :: inet:ip_address(),
1399                   Port :: inet:port_number()) ->
1400                      ok
1401
1402       stop_daemon(Address :: any | inet:ip_address(),
1403                   Port :: inet:port_number(),
1404                   Profile :: atom()) ->
1405                      ok
1406
1407              Stops the listener and all connections started by the listener.
1408
1409       stop_listener(SysSup :: daemon_ref()) -> ok
1410
1411       stop_listener(Address :: inet:ip_address(),
1412                     Port :: inet:port_number()) ->
1413                        ok
1414
1415       stop_listener(Address :: any | inet:ip_address(),
1416                     Port :: inet:port_number(),
1417                     Profile :: term()) ->
1418                        ok
1419
1420              Stops  the  listener, but leaves existing connections started by
1421              the listener operational.
1422
1423       tcpip_tunnel_from_server(ConnectionRef, ListenHost, ListenPort,
1424                                ConnectToHost, ConnectToPort) ->
1425                                   {ok, TrueListenPort} | {error, term()}
1426
1427       tcpip_tunnel_from_server(ConnectionRef, ListenHost, ListenPort,
1428                                ConnectToHost, ConnectToPort, Timeout) ->
1429                                   {ok, TrueListenPort} | {error, term()}
1430
1431              Types:
1432
1433                 ConnectionRef = connection_ref()
1434                 ListenHost = host()
1435                 ListenPort = inet:port_number()
1436                 ConnectToHost = host()
1437                 ConnectToPort = inet:port_number()
1438                 Timeout = timeout()
1439                 TrueListenPort = inet:port_number()
1440
1441              Asks the remote server of ConnectionRef  to  listen  to  Listen‐
1442              Host:ListenPort. When someone connects that address, the connec‐
1443              tion is forwarded in an encrypted channel from the server to the
1444              client.  The  client (that is, at the node that calls this func‐
1445              tion) then connects to ConnectToHost:ConnectToPort.
1446
1447              The returned TrueListenPort is the port that is listened to.  It
1448              is  the  same as ListenPort, except when ListenPort = 0. In that
1449              case a free port is selected by the underlying OS.
1450
1451              Note that in case of an Erlang/OTP SSH server (daemon) as  peer,
1452              that  server  must  have been started with the option tcpip_tun‐
1453              nel_out to allow the connection.
1454
1455       tcpip_tunnel_to_server(ConnectionRef, ListenHost, ListenPort,
1456                              ConnectToHost, ConnectToPort) ->
1457                                 {ok, TrueListenPort} | {error, term()}
1458
1459       tcpip_tunnel_to_server(ConnectionRef, ListenHost, ListenPort,
1460                              ConnectToHost, ConnectToPort, Timeout) ->
1461                                 {ok, TrueListenPort} | {error, term()}
1462
1463              Types:
1464
1465                 ConnectionRef = connection_ref()
1466                 ListenHost = host()
1467                 ListenPort = inet:port_number()
1468                 ConnectToHost = host()
1469                 ConnectToPort = inet:port_number()
1470                 Timeout = timeout()
1471                 TrueListenPort = inet:port_number()
1472
1473              Tells the local client to listen to ListenHost:ListenPort.  When
1474              someone connects to that address, the connection is forwarded in
1475              an encrypted channel to the peer server of  ConnectionRef.  That
1476              server then connects to ConnectToHost:ConnectToPort.
1477
1478              The  returned TrueListenPort is the port that is listened to. It
1479              is the same as ListenPort, except when ListenPort = 0.  In  that
1480              case a free port is selected by the underlying OS.
1481
1482              Note  that in case of an Erlang/OTP SSH server (daemon) as peer,
1483              that server must have been started with  the  option  tcpip_tun‐
1484              nel_in to allow the connection.
1485
1486       hostkey_fingerprint(HostKey) -> string()
1487       hostkey_fingerprint(DigestType, HostKey) -> string()
1488       hostkey_fingerprint([DigestType], HostKey) -> [string()]
1489
1490              Types:
1491
1492                 HostKey = public_key:public_key()
1493                 DigestType = public_key:digest_type()
1494
1495              Calculates  a  ssh fingerprint from a public host key as openssh
1496              does.
1497
1498              The algorithm in hostkey_fingerprint/1 is md5 to  be  compatible
1499              with older ssh-keygen commands. The string from the second vari‐
1500              ant is prepended by the algorithm name in uppercase as in  newer
1501              ssh-keygen commands.
1502
1503              Examples:
1504
1505               2> ssh:hostkey_fingerprint(Key).
1506               "f5:64:a6:c1:5a:cb:9f:0a:10:46:a2:5c:3e:2f:57:84"
1507
1508               3> ssh:hostkey_fingerprint(md5,Key).
1509               "MD5:f5:64:a6:c1:5a:cb:9f:0a:10:46:a2:5c:3e:2f:57:84"
1510
1511               4> ssh:hostkey_fingerprint(sha,Key).
1512               "SHA1:bSLY/C4QXLDL/Iwmhyg0PGW9UbY"
1513
1514               5> ssh:hostkey_fingerprint(sha256,Key).
1515               "SHA256:aZGXhabfbf4oxglxltItWeHU7ub3Dc31NcNw2cMJePQ"
1516
1517               6> ssh:hostkey_fingerprint([sha,sha256],Key).
1518               ["SHA1:bSLY/C4QXLDL/Iwmhyg0PGW9UbY",
1519                "SHA256:aZGXhabfbf4oxglxltItWeHU7ub3Dc31NcNw2cMJePQ"]
1520
1521
1522
1523
1524Ericsson AB                       ssh 4.12.5                            ssh(3)
Impressum