<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY COMMANDNAME "mandos">
<!ENTITY TIMESTAMP "2008-09-30">
<!ENTITY % common SYSTEM "common.ent">
%common;
]>

<refentry xmlns:xi="http://www.w3.org/2001/XInclude">
   <refentryinfo>
    <title>Mandos Manual</title>
    <!-- NWalsh’s docbook scripts use this to generate the footer: -->
    <productname>Mandos</productname>
    <productnumber>&version;</productnumber>
    <date>&TIMESTAMP;</date>
    <authorgroup>
      <author>
	<firstname>Björn</firstname>
	<surname>Påhlsson</surname>
	<address>
	  <email>belorn@fukt.bsnet.se</email>
	</address>
      </author>
      <author>
	<firstname>Teddy</firstname>
	<surname>Hogeborn</surname>
	<address>
	  <email>teddy@fukt.bsnet.se</email>
	</address>
      </author>
    </authorgroup>
    <copyright>
      <year>2008</year>
      <holder>Teddy Hogeborn</holder>
      <holder>Björn Påhlsson</holder>
    </copyright>
    <xi:include href="legalnotice.xml"/>
  </refentryinfo>
  
  <refmeta>
    <refentrytitle>&COMMANDNAME;</refentrytitle>
    <manvolnum>8</manvolnum>
  </refmeta>
  
  <refnamediv>
    <refname><command>&COMMANDNAME;</command></refname>
    <refpurpose>
      Gives encrypted passwords to authenticated Mandos clients
    </refpurpose>
  </refnamediv>
  
  <refsynopsisdiv>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <group>
	<arg choice="plain"><option>--interface
	<replaceable>NAME</replaceable></option></arg>
	<arg choice="plain"><option>-i
	<replaceable>NAME</replaceable></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--address
	<replaceable>ADDRESS</replaceable></option></arg>
	<arg choice="plain"><option>-a
	<replaceable>ADDRESS</replaceable></option></arg>
      </group>
      <sbr/>
      <group>
	<arg choice="plain"><option>--port
	<replaceable>PORT</replaceable></option></arg>
	<arg choice="plain"><option>-p
	<replaceable>PORT</replaceable></option></arg>
      </group>
      <sbr/>
      <arg><option>--priority
      <replaceable>PRIORITY</replaceable></option></arg>
      <sbr/>
      <arg><option>--servicename
      <replaceable>NAME</replaceable></option></arg>
      <sbr/>
      <arg><option>--configdir
      <replaceable>DIRECTORY</replaceable></option></arg>
      <sbr/>
      <arg><option>--debug</option></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <group choice="req">
	<arg choice="plain"><option>--help</option></arg>
	<arg choice="plain"><option>-h</option></arg>
      </group>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice="plain"><option>--version</option></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>&COMMANDNAME;</command>
      <arg choice="plain"><option>--check</option></arg>
    </cmdsynopsis>
  </refsynopsisdiv>
  
  <refsect1 id="description">
    <title>DESCRIPTION</title>
    <para>
      <command>&COMMANDNAME;</command> is a server daemon which
      handles incoming request for passwords for a pre-defined list of
      client host computers.  The Mandos server uses Zeroconf to
      announce itself on the local network, and uses TLS to
      communicate securely with and to authenticate the clients.  The
      Mandos server uses IPv6 to allow Mandos clients to use IPv6
      link-local addresses, since the clients will probably not have
      any other addresses configured (see <xref linkend="overview"/>).
      Any authenticated client is then given the stored pre-encrypted
      password for that specific client.
    </para>
  </refsect1>
  
  <refsect1 id="purpose">
    <title>PURPOSE</title>
    <para>
      The purpose of this is to enable <emphasis>remote and unattended
      rebooting</emphasis> of client host computer with an
      <emphasis>encrypted root file system</emphasis>.  See <xref
      linkend="overview"/> for details.
    </para>
  </refsect1>
  
  <refsect1 id="options">
    <title>OPTIONS</title>
    <variablelist>
      <varlistentry>
	<term><option>--help</option></term>
	<term><option>-h</option></term>
	<listitem>
	  <para>
	    Show a help message and exit
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--interface</option>
	<replaceable>NAME</replaceable></term>
	<term><option>-i</option>
	<replaceable>NAME</replaceable></term>
	<listitem>
	  <xi:include href="mandos-options.xml" xpointer="interface"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--address
	<replaceable>ADDRESS</replaceable></option></term>
	<term><option>-a
	<replaceable>ADDRESS</replaceable></option></term>
	<listitem>
	  <xi:include href="mandos-options.xml" xpointer="address"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--port
	<replaceable>PORT</replaceable></option></term>
	<term><option>-p
	<replaceable>PORT</replaceable></option></term>
	<listitem>
	  <xi:include href="mandos-options.xml" xpointer="port"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--check</option></term>
	<listitem>
	  <para>
	    Run the server’s self-tests.  This includes any unit
	    tests, etc.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--debug</option></term>
	<listitem>
	  <xi:include href="mandos-options.xml" xpointer="debug"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--priority <replaceable>
	PRIORITY</replaceable></option></term>
	<listitem>
	  <xi:include href="mandos-options.xml" xpointer="priority"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--servicename
	<replaceable>NAME</replaceable></option></term>
	<listitem>
	  <xi:include href="mandos-options.xml"
		      xpointer="servicename"/>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--configdir
	<replaceable>DIRECTORY</replaceable></option></term>
	<listitem>
	  <para>
	    Directory to search for configuration files.  Default is
	    <quote><literal>/etc/mandos</literal></quote>.  See
	    <citerefentry><refentrytitle>mandos.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> and <citerefentry>
	    <refentrytitle>mandos-clients.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry>.
	  </para>
	</listitem>
      </varlistentry>
      
      <varlistentry>
	<term><option>--version</option></term>
	<listitem>
	  <para>
	    Prints the program version and exit.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  
  <refsect1 id="overview">
    <title>OVERVIEW</title>
    <xi:include href="overview.xml"/>
    <para>
      This program is the server part.  It is a normal server program
      and will run in a normal system environment, not in an initial
      <acronym>RAM</acronym> disk environment.
    </para>
  </refsect1>
  
  <refsect1 id="protocol">
    <title>NETWORK PROTOCOL</title>
    <para>
      The Mandos server announces itself as a Zeroconf service of type
      <quote><literal>_mandos._tcp</literal></quote>.  The Mandos
      client connects to the announced address and port, and sends a
      line of text where the first whitespace-separated field is the
      protocol version, which currently is
      <quote><literal>1</literal></quote>.  The client and server then
      start a TLS protocol handshake with a slight quirk: the Mandos
      server program acts as a TLS <quote>client</quote> while the
      connecting Mandos client acts as a TLS <quote>server</quote>.
      The Mandos client must supply an OpenPGP certificate, and the
      fingerprint of this certificate is used by the Mandos server to
      look up (in a list read from <filename>clients.conf</filename>
      at start time) which binary blob to give the client.  No other
      authentication or authorization is done by the server.
    </para>
    <table>
      <title>Mandos Protocol (Version 1)</title><tgroup cols="3"><thead>
      <row>
	<entry>Mandos Client</entry>
	<entry>Direction</entry>
	<entry>Mandos Server</entry>
      </row>
      </thead><tbody>
      <row>
	<entry>Connect</entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry><quote><literal>1\r\n</literal></quote></entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry>TLS handshake <emphasis>as TLS <quote>server</quote>
	</emphasis></entry>
	<entry>&lt;-><!-- &xharr; --></entry>
	<entry>TLS handshake <emphasis>as TLS <quote>client</quote>
	</emphasis></entry>
      </row>
      <row>
	<entry>OpenPGP public key (part of TLS handshake)</entry>
	<entry>-><!-- &rarr; --></entry>
      </row>
      <row>
	<entry/>
	<entry>&lt;-<!-- &larr; --></entry>
	<entry>Binary blob (client will assume OpenPGP data)</entry>
      </row>
      <row>
	<entry/>
	<entry>&lt;-<!-- &larr; --></entry>
	<entry>Close</entry>
      </row>
    </tbody></tgroup></table>
  </refsect1>
  
  <refsect1 id="checking">
    <title>CHECKING</title>
    <para>
      The server will, by default, continually check that the clients
      are still up.  If a client has not been confirmed as being up
      for some time, the client is assumed to be compromised and is no
      longer eligible to receive the encrypted password.  The timeout,
      checker program, and interval between checks can be configured
      both globally and per client; see <citerefentry>
      <refentrytitle>mandos-clients.conf</refentrytitle>
      <manvolnum>5</manvolnum></citerefentry>.
    </para>
  </refsect1>
  
  <refsect1 id="logging">
    <title>LOGGING</title>
    <para>
      The server will send log message with various severity levels to
      <filename>/dev/log</filename>.  With the
      <option>--debug</option> option, it will log even more messages,
      and also show them on the console.
    </para>
  </refsect1>
  
  <refsect1 id="exit_status">
    <title>EXIT STATUS</title>
    <para>
      The server will exit with a non-zero exit status only when a
      critical error is encountered.
    </para>
  </refsect1>
  
  <refsect1 id="environment">
    <title>ENVIRONMENT</title>
    <variablelist>
      <varlistentry>
	<term><envar>PATH</envar></term>
	<listitem>
	  <para>
	    To start the configured checker (see <xref
	    linkend="checking"/>), the server uses
	    <filename>/bin/sh</filename>, which in turn uses
	    <varname>PATH</varname> to search for matching commands if
	    an absolute path is not given.  See <citerefentry>
	    <refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum>
	    </citerefentry>.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  
  <refsect1 id="file">
    <title>FILES</title>
    <para>
      Use the <option>--configdir</option> option to change where
      <command>&COMMANDNAME;</command> looks for its configurations
      files.  The default file names are listed here.
    </para>
    <variablelist>
      <varlistentry>
	<term><filename>/etc/mandos/mandos.conf</filename></term>
	<listitem>
	  <para>
	    Server-global settings.  See
	    <citerefentry><refentrytitle>mandos.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> for details.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/etc/mandos/clients.conf</filename></term>
	<listitem>
	  <para>
	    List of clients and client-specific settings.  See
	    <citerefentry><refentrytitle>mandos-clients.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> for details.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/var/run/mandos.pid</filename></term>
	<listitem>
	  <para>
	    The file containing the process id of
	    <command>&COMMANDNAME;</command>.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/dev/log</filename></term>
	<listitem>
	  <para>
	    The Unix domain socket to where local syslog messages are
	    sent.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><filename>/bin/sh</filename></term>
	<listitem>
	  <para>
	    This is used to start the configured checker command for
	    each client.  See <citerefentry>
	    <refentrytitle>mandos-clients.conf</refentrytitle>
	    <manvolnum>5</manvolnum></citerefentry> for details.
	  </para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
  
  <refsect1 id="bugs">
    <title>BUGS</title>
    <para>
      This server might, on especially fatal errors, emit a Python
      backtrace.  This could be considered a feature.
    </para>
    <para>
      Currently, if a client is declared <quote>invalid</quote> due to
      having timed out, the server does not record this fact onto
      permanent storage.  This has some security implications, see
      <xref linkend="CLIENTS"/>.
    </para>
    <para>
      There is currently no way of querying the server of the current
      status of clients, other than analyzing its <systemitem
      class="service">syslog</systemitem> output.
    </para>
    <para>
      There is no fine-grained control over logging and debug output.
    </para>
    <para>
      Debug mode is conflated with running in the foreground.
    </para>
    <para>
      The console log messages does not show a time stamp.
    </para>
    <para>
      This server does not check the expire time of clients’ OpenPGP
      keys.
    </para>
  </refsect1>
  
  <refsect1 id="example">
    <title>EXAMPLE</title>
    <informalexample>
      <para>
	Normal invocation needs no options:
      </para>
      <para>
	<userinput>&COMMANDNAME;</userinput>
      </para>
    </informalexample>
    <informalexample>
      <para>
	Run the server in debug mode, read configuration files from
	the <filename>~/mandos</filename> directory, and use the
	Zeroconf service name <quote>Test</quote> to not collide with
	any other official Mandos server on this host:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>&COMMANDNAME; --debug --configdir ~/mandos --servicename Test</userinput>

      </para>
    </informalexample>
    <informalexample>
      <para>
	Run the server normally, but only listen to one interface and
	only on the link-local address on that interface:
      </para>
      <para>

<!-- do not wrap this line -->
<userinput>&COMMANDNAME; --interface eth7 --address fe80::aede:48ff:fe71:f6f2</userinput>

      </para>
    </informalexample>
  </refsect1>
  
  <refsect1 id="security">
    <title>SECURITY</title>
    <refsect2 id="SERVER">
      <title>SERVER</title>
      <para>
	Running this <command>&COMMANDNAME;</command> server program
	should not in itself present any security risk to the host
	computer running it.  The program switches to a non-root user
	soon after startup.
      </para>
    </refsect2>
    <refsect2 id="CLIENTS">
      <title>CLIENTS</title>
      <para>
	The server only gives out its stored data to clients which
	does have the OpenPGP key of the stored fingerprint.  This is
	guaranteed by the fact that the client sends its OpenPGP
	public key in the TLS handshake; this ensures it to be
	genuine.  The server computes the fingerprint of the key
	itself and looks up the fingerprint in its list of
	clients. The <filename>clients.conf</filename> file (see
	<citerefentry><refentrytitle>mandos-clients.conf</refentrytitle>
	<manvolnum>5</manvolnum></citerefentry>)
	<emphasis>must</emphasis> be made non-readable by anyone
	except the user starting the server (usually root).
      </para>
      <para>
	As detailed in <xref linkend="checking"/>, the status of all
	client computers will continually be checked and be assumed
	compromised if they are gone for too long.
      </para>
      <para>
	If a client is compromised, its downtime should be duly noted
	by the server which would therefore declare the client
	invalid.  But if the server was ever restarted, it would
	re-read its client list from its configuration file and again
	regard all clients therein as valid, and hence eligible to
	receive their passwords.  Therefore, be careful when
	restarting servers if it is suspected that a client has, in
	fact, been compromised by parties who may now be running a
	fake Mandos client with the keys from the non-encrypted
	initial <acronym>RAM</acronym> image of the client host.  What
	should be done in that case (if restarting the server program
	really is necessary) is to stop the server program, edit the
	configuration file to omit any suspect clients, and restart
	the server program.
      </para>
      <para>
	For more details on client-side security, see
	<citerefentry><refentrytitle>mandos-client</refentrytitle>
	<manvolnum>8mandos</manvolnum></citerefentry>.
      </para>
    </refsect2>
  </refsect1>
  
  <refsect1 id="see_also">
    <title>SEE ALSO</title>
    <para>
      <citerefentry>
	<refentrytitle>mandos-clients.conf</refentrytitle>
	<manvolnum>5</manvolnum></citerefentry>, <citerefentry>
	<refentrytitle>mandos.conf</refentrytitle>
	<manvolnum>5</manvolnum></citerefentry>, <citerefentry>
	<refentrytitle>mandos-client</refentrytitle>
	<manvolnum>8mandos</manvolnum></citerefentry>, <citerefentry>
	<refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum>
      </citerefentry>
    </para>
    <variablelist>
      <varlistentry>
	<term>
	  <ulink url="http://www.zeroconf.org/">Zeroconf</ulink>
	</term>
	<listitem>
	  <para>
	    Zeroconf is the network protocol standard used by clients
	    for finding this Mandos server on the local network.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <ulink url="http://www.avahi.org/">Avahi</ulink>
	</term>
      <listitem>
	<para>
	  Avahi is the library this server calls to implement
	  Zeroconf service announcements.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  <ulink url="http://www.gnu.org/software/gnutls/"
	  >GnuTLS</ulink>
	</term>
      <listitem>
	<para>
	  GnuTLS is the library this server uses to implement TLS for
	  communicating securely with the client, and at the same time
	  confidently get the client’s public OpenPGP key.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 4291: <citetitle>IP Version 6 Addressing
	  Architecture</citetitle>
	</term>
	<listitem>
	  <variablelist>
	    <varlistentry>
	      <term>Section 2.2: <citetitle>Text Representation of
	      Addresses</citetitle></term>
	      <listitem><para/></listitem>
	    </varlistentry>
	    <varlistentry>
	      <term>Section 2.5.5.2: <citetitle>IPv4-Mapped IPv6
	      Address</citetitle></term>
	      <listitem><para/></listitem>
	    </varlistentry>
	    <varlistentry>
	    <term>Section 2.5.6, <citetitle>Link-Local IPv6 Unicast
	    Addresses</citetitle></term>
	    <listitem>
	      <para>
		The clients use IPv6 link-local addresses, which are
		immediately usable since a link-local addresses is
		automatically assigned to a network interfaces when it
		is brought up.
	      </para>
	    </listitem>
	    </varlistentry>
	  </variablelist>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 4346: <citetitle>The Transport Layer Security (TLS)
	  Protocol Version 1.1</citetitle>
	</term>
      <listitem>
	<para>
	  TLS 1.1 is the protocol implemented by GnuTLS.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 4880: <citetitle>OpenPGP Message Format</citetitle>
	</term>
      <listitem>
	<para>
	  The data sent to clients is binary encrypted OpenPGP data.
	</para>
      </listitem>
      </varlistentry>
      <varlistentry>
	<term>
	  RFC 5081: <citetitle>Using OpenPGP Keys for Transport Layer
	  Security</citetitle>
	</term>
      <listitem>
	<para>
	  This is implemented by GnuTLS and used by this server so
	  that OpenPGP keys can be used.
	</para>
      </listitem>
      </varlistentry>
    </variablelist>
  </refsect1>
</refentry>
<!-- Local Variables: -->
<!-- time-stamp-start: "<!ENTITY TIMESTAMP [\"']" -->
<!-- time-stamp-end: "[\"']>" -->
<!-- time-stamp-format: "%:y-%02m-%02d" -->
<!-- End: -->
