.. highlight:: kotlin .. raw:: html Shell ===== The Corda shell is an embedded command line that allows an administrator to control and monitor the node. Some of its features include: * Invoking any of the RPCs the node exposes to applications. * Starting flows. * View a dashboard of threads, heap usage, VM properties. * Uploading and downloading zips from the attachment store. * Issue SQL queries to the underlying database. * View JMX metrics and monitoring exports. * UNIX style pipes for both text and objects, an ``egrep`` command and a command for working with columnular data. It is based on the popular `CRaSH`_ shell used in various other projects and supports many of the same features. Local terminal shell runs only in development mode. It may be disabled by passing the ``--no-local-shell`` flag to the node. SSH server ---------- Shell can also be accessible via SSH. By default SSH server is *disabled*. To enable it port must be configured - in ``node.conf`` file .. code:: bash sshd { port = 2222 } Authentication and authorization -------------------------------- SSH requires users to login first - using the same users as RPC system. In fact, the shell serves as a proxy to RPC and communicates with the node using RPC calls. This also means that RPC permissions are enforced. No permissions are required to allow the connection and log in. Watching flows (``flow watch``) requires ``InvokeRpc.stateMachinesFeed`` while starting flows requires ``InvokeRpc.startTrackedFlowDynamic`` and ``InvokeRpc.registeredFlows`` in addition to a permission for a particular flow. Host key -------- The host key is loaded from ``sshkey/hostkey.pem`` file. If the file does not exist, it will be generated randomly, however in the development mode seed may be tuned to give the same results on the same computer - in order to avoid host checking errors. Connecting ---------- Linux and MacOS computers usually come with SSH client preinstalled. On Windows it usually requires extra download. Usual connection syntax is ``ssh user@host -p 2222`` - where ``user`` is a RPC username, and ``-p`` specifies a port parameters - it's the same as setup in ``node.conf`` file. ``host`` should point to a node hostname, usually ``localhost`` if connecting and running node on the same computer. Password will be asked after establishing connection. :note: While developing, checking multiple samples or simply restarting a node frequently host key may be regenerated. SSH usually saved once trusted hosts and will refuse to connect in case of a change. Then check may be disabled with extra options ``ssh -o StrictHostKeyChecking=no user@host -p2222``. This option should never be used in production environment! Getting help ------------ You can run ``help`` to list the available commands. The shell has a ``man`` command that can be used to get interactive help on many commands. You can also use the ``--help`` or ``-h`` flags to a command to get info about what switches it supports. Commands may have subcommands, in the same style as ``git``. In that case running the command by itself will list the supported subcommands. Starting flows and performing remote method calls ------------------------------------------------- **Flows** are the way the ledger is changed. If you aren't familiar with them, please review ":doc:`flow-state-machines`" first. The ``flow list`` command can be used to list the flows understood by the node, ``flow watch`` shows all the flows currently running on the node with the result (or error) information in a user friendly way, ``flow start`` can be used to start flows. The ``flow start`` command takes the class name of a flow, or *any unambiguous substring* and then the data to be passed to the flow constructor. The unambiguous substring feature is helpful for reducing the needed typing. If the match is ambiguous the possible matches will be printed out. If a flow has multiple constructors then the names and types of the arguments will be used to try and determine which to use automatically. If the match against available constructors is unclear, the reasons each available constructor failed to match will be printed out. In the case of an ambiguous match, the first applicable will be used. **RPCs** (remote procedure calls) are commands that can be sent to the node to query it, control it and manage it. RPCs don't typically do anything that changes the global ledger, but they may change node-specific data in the database. Each RPC is one method on the ``CordaRPCOps`` interface, and may return a stream of events that will be shown on screen until you press Ctrl-C. You perform an RPC by using ``run`` followed by the name. .. raw:: html