api-servers.texi 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. @c -*-texinfo-*-
  2. @c This file is part of Guile-SSH Reference Manual.
  3. @c Copyright (C) 2014 Artyom V. Poptsov
  4. @c See the file guile-ssh.texi for copying conditions.
  5. @node Servers
  6. @section Servers
  7. @cindex servers
  8. @tindex server
  9. The @code{(ssh server)} module provides facilities for creation and
  10. managing of Guile-SSH servers.
  11. @deffn {Scheme Procedure} server? x
  12. Return @code{#t} if @var{x} is a Guile-SSH server, @code{#f}
  13. otherwise.
  14. @end deffn
  15. @deffn {Scheme Procedure} %make-server
  16. Make a new Guile-SSH server.
  17. @end deffn
  18. @deffn {Scheme Procedure} make-server [keywords]
  19. Make a new Guile-SSH server with the specified configuration specified
  20. by keywords. Return a new Guile-SSH server.
  21. Example:
  22. @lisp
  23. (let ((s (make-server #:bindport 12345
  24. #:rsakey "/home/bob/.ssh/id_rsa"
  25. #:log-verbosity 'nolog)))
  26. ...)
  27. @end lisp
  28. @end deffn
  29. @deffn {Scheme Procedure} server-set! server option value
  30. Set a @var{option} to @var{value} for Guile-SSH @var{server}. Throw
  31. @code{guile-ssh-error} on error. Return value is undefined.
  32. Here is the description of available options. The description is
  33. based on libssh documentation:
  34. @table @samp
  35. @item bindaddr
  36. Set the bind address for the @var{server}.
  37. Expected type of @var{value}: string.
  38. @item bindport
  39. Set the bind port for the @var{server}, default is 22.
  40. Expected type of @var{value}: number.
  41. @item hostkey
  42. Set the @var{server} public key type: ``ssh-rsa'' or ``ssh-dss''.
  43. @strong{libssh 0.7 note:} you should pass a path to an ssh key for this
  44. option. Only one key from per key type (RSA, DSA, ECDSA) is allowed in an
  45. server at a time, and later calls to @code{server-set!} with this option for
  46. the same key type will override prior calls.
  47. Expected type of @var{value}: string.
  48. @item dsakey
  49. Set the path to the @acronym{SSH} host @acronym{DSA} key.
  50. Expected type of @var{value}: string.
  51. @item rsakey
  52. Set the path to the @acronym{SSH} host @acronym{RSA} key.
  53. Expected type of @var{value}: string.
  54. @item banner
  55. Set the @var{server} banner sent to clients.
  56. Expected type of @var{value}: string.
  57. @item log-verbosity
  58. Set the logging verbosity. Possible values:
  59. @table @samp
  60. @item nolog
  61. No logging at all
  62. @item rare
  63. Only rare and noteworthy events
  64. @item protocol
  65. High level protocol information
  66. @item packet
  67. Lower level protocol infomations, packet level
  68. @item functions
  69. Every function path
  70. @end table
  71. Expected type of @var{value}: symbol.
  72. @item blocking-mode
  73. Set the @var{server} to blocking/nonblocking mode according to
  74. @var{value}. The @var{value} is expected to be @code{#t} or
  75. @code{#f}.
  76. Expected type of @var{value}: boolean.
  77. @end table
  78. @end deffn
  79. @deffn {Scheme Procedure} server-get server option
  80. Get value of @var{option} for Guile-SSH @var{server}. Return @var{option}
  81. value, or @code{#f} if the @var{option} does not set. Throw
  82. @code{guile-ssh-error} on error.
  83. @end deffn
  84. @deffn {Scheme Procedure} server-listen server
  85. Start listening to the socket. Throw @code{guile-ssh-error} on error.
  86. Return value undefined.
  87. @end deffn
  88. @deffn {Scheme Procedure} server-accept server
  89. Accept an incoming @acronym{SSH} connection to the @var{server}.
  90. Return a new Guile-SSH session. Throw @code{guile-ssh-error} on error.
  91. Example:
  92. @lisp
  93. (let ((session (catch 'guile-ssh-error
  94. (lambda ()
  95. (server-accept server))
  96. (lambda (key . args)
  97. ;; Handle error
  98. #f))))
  99. ...)
  100. @end lisp
  101. One of the possible causes of errors might be that your server has no
  102. access to host keys.
  103. If you get an exception and it shows no cause of the error then try to
  104. set @code{log-verbosity} to a value other than @code{nolog} (e.g. to
  105. @code{rare}, see @code{server-set!} above) and check printouts from
  106. the libssh.
  107. @end deffn
  108. @deffn {Scheme Procedure} server-handle-key-exchange session
  109. Handle key exchange for a @var{session} and setup encryption. Throw
  110. @code{guile-ssh-error} on error. Return value is undefined.
  111. @end deffn
  112. @deffn {Scheme Procedure} server-message-get session
  113. Get a message from a SSH client (@pxref{Messages}). Return a new
  114. Guile-SSH message, or @code{#f} on error.
  115. @end deffn
  116. @c Local Variables:
  117. @c TeX-master: "guile-ssh.texi"
  118. @c End: