|Did you know ...||Search Documentation:|
|Pack libssh -- prolog/ssh_server.pl|
This module defines an embedded SSH server for SWI-Prolog on top of libssh. This module allows for a safe secondary access point to a running Prolog process. A typical use case is to provide a safe channal or inspection and maintenance of servers or embedded Prolog instances.
If possible, a login to the Prolog process uses a pseudo terminal to
realise normal terminal interaction, including processing of ^C to
interrupt running queries. If
libedit (editline) is used as the
command line editor this is installed (see el_wrap/0), providing
advanced command line editing and history.
The library currently support login to the Prolog process. Future versions may also use the client access and exploit the SSH subsystem interface to achieve safe interaction between Prolog peers.
A new connection creates a Prolog thread that handles the connection.
The new thread's standard streams (
current_output) are attached to the
new connection. Some of the environment is shared as Prolog flags. The
following flags are defined:
TERMenvironment variable passed from the client.
If a pseudo terminal is used and the
ssh_term flag is not
library(ansi_term) is connected to provide colorized output.
If a pseudo terminal is used and library(editline) is available, this library is used to enable command line editing.
ssh <options> <server> <command>,
<command> is executed
without a terminal (unless the
-t option is given to
ssh to force
a terminal) and otherwise as a single Prolog toplevel command. For
ssh -p 2020 localhost "writeln('Hello world')" Hello world true.
If the query is nondeterministic alternative answers can be requested in the same way as using the interactive toplevel. The exit code is defined as follows:
If a Prolor process with an embedded ssh server misbehaves it can be
forcefully aborted using the
abort command. This calls C
soon as possible and thus should function even if Prolog is, for
example, stuck in a deadlock.
ssh -p 2020 localhost abort
*to grant acccess from all network interfaces.
etc/sshbelow the current directory and
~/.config/swi-prolog/etc/ssh). On failure it creates, a directory
etc/sshwith default host keys and uses these.
auth_methods([public_key]). This file is in OpenSSH format and contains a certificate per line in the format
<type> <base64-key> <comment>
The the file `~/.ssh/authorized_keys` is present, this will
be used as default, granting anyone with access to this account
to access the server with the same keys. If the option is
present with value
 (empty list), no key file is used.
?- capture_messages(debug). ?- trace(p/1).
The following predicates are exported, but not or incorrectly documented.