<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<article id="index">

<artheader>

   <title>A syssies guide to <command>(ssh)console</command> and <command>conserver</command>.</title>

   <author>
      <firstname>Iain</firstname>
      <surname>Rae</surname>
      <affiliation>
         <orgname>Division of Informatics</orgname>
         <address>
            <email>iainr@dcs.ed.ac.uk</email>
         </address>
      </affiliation>
   </author>

   <revhistory>
      <revision>
         <revnumber>$Revision: 1.3 $
	 </revnumber>
         <date>$Date: 2001/04/25 09:14:13 $</date>
         <authorinitials>$Author: iainr $</authorinitials>
         <revremark>Incomplete draft.</revremark>
      </revision>
   </revhistory>

   <abstract>
	<para>This document is a basic guide to using the <ulink url="http://www.conserver.com">conserver</ulink> console server program within the division. It covers the use of the <command>sshconsole</command> and <command>console</command> commands, issues relating to the hardware and the specifics of the local configuration.</para>

   </abstract>
</artheader>
<sect1><title>Overview</title><para>The Division maintains a number of console servers in order to remotely administer some of our servers. Each server is configured to provide a console session on a the first serial port (com1 on PC's, ttya on workstations), which is in turn linked via a series of RJ45 and DB9/25 serial connections to a serial port on the PC acting as the console server. A daemon, <command>conserver</command>, runs on each console server allowing network access. <command>(ssh)console</command> allows administrators to connect to the appropriate console server and access any console.</para></sect1>
<sect1><title><command>console</command></title>
	<para><cmdsynopsis><command>console</command><arg>-aAfFsS]</arg><arg>-rv</arg><arg>-e esc</arg><arg>-M server</arg><arg>host</arg></cmdsynopsis>
	</para>
	<para><command>console</command> is a client command which establishes a session with the appropriate conserver daemon running on a PC with a serial connection to the console specified on the command line. When invoked <command>console</command> connects to the master <command>conserver</command> server to establish which server is physically attached to the console you wish to connect to. If the console is not on one of the master server's serial ports <command>console</command> drops the connection and connects to the server which is attached.</para><para>Since <command>console</command> does not support encryption you should use <command>sshconsole</command> which does and takes the same arguments.
	</para>
</sect1> 

<sect1><title>Using <command>sshconsole</command> interactively</title>
	<para><cmdsynopsis><command>sshconsole</command><arg>-aAfFsS</arg><arg>-rv</arg><arg>-e escape sequence</arg><arg>-M server</arg><arg>host</arg></cmdsynopsis>
	</para>
	<para><command>sshconsole</command> is a wrapper script using <command>ssh</command>. <command>console</command> does not support encrypted connections and it is not possible to tunnel the connections through ssh, kerberos or ssl. <command>sshconsole</command> establishes a transparent ssh connection to the console server and runs <command>console</command> locally, and command line arguments are passed though to <command>console</command> so any valid <command>console</command> arguments can be used though the use of <cmdsynopsis> <command>sshconsole</command><arg>-M hostname</arg></cmdsynopsis> is discouraged.
	</para>
	<sect2><title>Basic usage</title>
		<para>To connect to the serial console on a host run sshconsole with the hostname as an argument, the script should connect to the appropriate host and ask for your password (it uses the username of whoever has run the script). i.e.
		<screen>

[magrathea]iainr: sshconsole heather
Enter iainr's password:
[Enter `^]^]?' for help] <co id="escape">
[replay] <co id="replay">
Password: 
.



Login incorrect
heather console login: Password: 
^C^E
Login incorrect
heather console login: heather console login:         ^[     
Password: 
Login incorrect
heather console login: 
heather console login: 
heather console login: 
heather console login: ^C^E
heather console login: .
Password: 
heather console login: 
		</screen>
		<calloutlist>
			<callout arearefs="escape">
				<para>This prompt may vary on how the escape sequence is defined, you can override the built in default of <command>^]^]</command> using the <command>-e</command> argument.
				</para>
			</callout>
			<callout arearefs="replay">
				<para>By default sshconsole will connect using the -A option which will replay the previous 20 lines, if you override with the -a option then you may have to hit &lt;cr> a couple of times to get the console.</para>
			</callout>
		</calloutlist>
		</para>
		<para>Once attached the terminal should behave as if you were using a dumb terminall physically attached to the serial console. Depending on which program you are using there may be problems with control key combinations if you hit any then let me know <email>iainr@dcs.ed.ac.ac.uk</email> and I'll take a look. 
		</para>
		<para>If you want to use any of the conserver features then you need to drop out of the session using the escape sequence followed by the one character command. For a list of commands hit the escape sequence followed by ?.
		</para>
		<para>i.e.
		<screen>
[magrathea]iainr: sshconsole heather
Enter iainr's password:
[Enter `^]^]?' for help]

heather console login: [help] <co id="prompt">
 .    disconnect                         a    attach read/write
 c    toggle flow control                d    down a console
 e    change escape sequence             f    force attach read/write
 g    group info                         L    toggle logging on/off
 l1   send break (halt host!)            o    (re)open the tty and log file
 p    replay the last 60 lines           r    replay the last 20 lines
 s    spy read only                      u    show host status
 v    show version info                  w    who is on this console
 x    show console baud info             z    suspend the connection
 &lt;cr> ignore/abort command               ?    print this message
 ^R   short replay                       \ooo send character by octal code
		</screen>
		<calloutlist>
			<callout arearefs="prompt">
				<para>This will display a <prompt>[</prompt> prompt when you type the control sequence and fill in the rest when you hit the 1 character command.
				</para>
			</callout>
		</calloutlist>
		</para>
	</sect2>
	<sect2><title>Disconnecting</title>
		<para>hitting <command>^]^].</command> will cause the session to terminate.
		</para>
		<screen>
[magrathea]iainr: sshconsole heather
Enter iainr's password:
[Enter `^]^]?' for help]

heather console login: [disconnect]
Connection to console closed.
		</screen>
	</sect2>
</sect1>
<sect1><title>Non-interactive commands</title>
	<cmdsynopsis><command>sshconsole</command><arg>-v</arg> <arg>-hdDuVwx</arg> <arg>-b message</arg></cmdsynopsis>
	<para>We can use <command>sshconsole</command> without actually logging in to do a number of things, seeing who is attached to which consoles, console status, broadcasting messages and information about the daemons
	</para>
<sect2><title>"who" and console status</title><para>The -u, -w and -x commands provide information about the status of the consoles, who is attached and what consoles are active respectively.</para>
<para>examples</para>
<screen>
[marmion]iainr: ./sshconsole -u
servers are:claise
 minibw1                    up   &lt;none>
 minibw2                    up   &lt;none>
 heather                    up   iainr@
 deadhost                   up   &lt;none>
Connection to claise closed.
[marmion]iainr: ./sshconsole -w
servers are:claise
 iainr@                     attach   0:00 heather
Connection to claise closed.
[marmion]iainr: ./sshconsole -x
servers are:claise
 minibw1                  on /dev/ttyS0                       at  9600p
 minibw2                  on /dev/ttyS1                       at  9600p
 heather                  on /dev/cub0                        at  9600p
 deadhost                 on /dev/cub31                       at  9600p
Connection to claise closed.
</screen>
<para>sshconsole will show the servers it is polling for information, if it fails to connect you will get an error message. NB the <quote>up</quote> reported by -u refers to the port connection within conserver, not to whether there is anything active on the port. In the example above there is nothing connected to /dev/cub31.</para>
</sect2>
<sect2><title>Broadcasting messages</title><para>we can send short messages using the -b option, these should be quoted. The message will be broadcast on all consoles on all servers (that sshconsole can find in lcfg), there is currently no way of sending messages to a specific console or user. sshconsole will pooll servers in turn attempting to send the message, you will get error messages if it cannot connect but won't stop until it has tried all servers.</para>
<screen>[marmion]iainr: ./sshconsole -b "this is a test"
servers are:claise
Connection to claise closed.
[marmion]iainr: 
</screen>
<para>Anyone attached will see</para>
<screen>



Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.16_public-3.dcs.9 on an i686

minibw1.dcs.ed.ac.uk login: [-- Console server shutting down --]
Connection to console closed.
[magrathea]iainr: sshconsole heather
Enter iainr's password:
[Enter `^Ec?' for help]

heather console login: [Broadcast: this is a test]


</screen>
</sect2>
</sect1>
<sect1><title>Spying and bumping other users</title>
	<cmdsynopsis><command>sshconsole</command> <arg>-s</arg> <arg>-S</arg> <arg>-f</arg> <arg>-F</arg></cmdsynopsis>
	<cmdsynopsis><arg>^]^]f</arg> <arg>^]^]F</arg> <arg>^]^]s</arg> <arg>^]^]S</arg></cmdsynopsis>

	<para>Conserver allows multiple users to be connected to a console but only one can be using the console at any one time (is attached). Usually this will be the first person to connect, and any subsequent connection will be read only (spy mode). If this is the case then running <command> sshconsole -w</command> will show who is attached and who is running in spy mode,
	<screen>
[magrathea]iainr: sshconsole -w 
 gmdr@                     spy      0:00 heather
 iainr@                     attach   0:00 heather
Connection to console closed.
[magrathea]iainr: 
	</screen>
 doing <command>^]^]w</command> will show similar information if you are using sshconsole. 
	<screen>
Enter foo's password:
[Enter `^]^]?' for help]
[no, iainr@ is attached] <co id="attached">
[read-only -- use ^E c ? for help]
iainr
Password: 
Last login: Fri Mar  9 14:39:27 from allan.dcs.ed.ac.
CTRL/C To stop x11
^C[heather]iainr: [who heather]
 foo@                   * spy      0:00 Sun Mar 11 18:14:53 2001 <co id="who">
 iainr@                     attach   0:04 Sun Mar 11 18:14:34 2001
	</screen>
	<calloutlist>
		<callout arearefs="attached">
			<para>iainr is already attached to this console so foo drops to read-only (spy) mode.
			</para>
		</callout>
		<callout arearefs="who">
			<para>The <quote>*</quote> indicates which session this is.
			</para>
		</callout>
	</calloutlist>
	</para>
	<para>If we need to get access to a console and someone else is attached we can take over (bump) their session, this will show a message on the other user's screen showing who has taken over the session.
	</para>
	<screen>
[claise]foo: sshconsole  heather
Enter foo's password:
[Enter `^]^]?' for help]
[no, iainr@ is attached]
[replay]<co id="fooreplay">

heather console login: 
heather console login: iainr
Password: 
Last login: Mon Mar 12 09:43:53 on console
CTRL/C To stop x11
^C[heather]iainr: pwd
/a/bigga/disk/home/u8/iainr
[heather]iainr: [who heather] 
 foo@                   * spy      0:00 Mon Mar 12 09:48:27 2001
 iainr@                     attach   0:00 Mon Mar 12 09:47:56 2001
[bumped iainr@]<co id="bumpiainr">

[heather]iainr: ls
6.2installdir.tgz
806-3814.pdf
Articles
Astronomy-HOWTO.sgml
Astronomy-HOWTO.tex
DEADJOE
Desktop
Mail
News
annex.def
[heather]iainr: [who heather]<co id="fooattached">
 foo@                   * attach   0:00 Mon Mar 12 09:48:27 2001
 iainr@                     spy      0:07 Mon Mar 12 09:47:56 2001

	</screen>
	<calloutlist>
		<callout arearefs="fooreplay">
			<para>foo logs in and as iainr is attached drops into spy mode, foo gets to see the last 20 lines on the console.
			</para>
		</callout>
		<callout arearefs="bumpiainr">
			<para>foo takes over the console by hitting excape_sequence f, iainr drops back to spy mode
			</para>
		</callout>
		<callout arearefs="fooattached">
			<para>If foo does ^]^]w we can see that he is now shown as attached
			</para>
		</callout>

	</calloutlist>
	<para>The equivalent session shown on iainr's terminal looks like.
	<screen>
[magrathea]iainr: sshconsole heather
Enter iainr's password: <co id="iainlogin">
[Enter `^]^]?' for help]

heather console login: iainr
Password: 
Last login: Mon Mar 12 09:43:53 on console
CTRL/C To stop x11
^C[heather]iainr: pwd
/a/bigga/disk/home/u8/iainr
[heather]iainr: 
[forced to `spy' mode by foo@]<co id="iainbumped">

[heather]iainr: ls
6.2installdir.tgz
806-3814.pdf
Articles
Astronomy-HOWTO.sgml
Astronomy-HOWTO.tex
DEADJOE
Desktop
Mail
News
annex.def
	</screen>
	<calloutlist>
		<callout arearefs="iainlogin">
			<para>iainr logs in and starts doing things.
			</para>
		</callout>
		<callout arearefs="iainbumped">
			<para>foo has bumped iainr and iainr's session is now read-only (spy)
			</para>
		</callout>
	</calloutlist>
	</para>
</sect1>
<sect1><title>Maintaining the server</title><para>This section gives step-by step instructions on adding and removing consoles and some things to watch out for.<comment>At the moment this section will only cover the server area in KB since that's all I know about :)</comment></para>
<sect2><title>Adding consoles.</title>
	<orderedlist numeration="arabic">
	<listitem>
		<para>Configure your server to use a serial console.				<itemizedlist mark=opencircle>
			<listitem><para>Linux: add #include &lt;linux_serialconsole.h> to the lcfg entry for the host.</para>
			</listitem>
			<listitem><para>Solaris: add install.console         vt100 to lcfg entry.</para>
			</listitem>
		</itemizedlist></para>
	</listitem>
	<listitem><para>Plumb your serial cable in, the console servers are patched into patch panel X on rack 7. <comment>This section needs to be expanded once we actually know what's physically happening and should detail how the ports map to serial devices and how panels map to console servers (if we have more than one).</comment></para>
	</listitem>
	<listitem><para>Now fire up rfe and edit the lcfg entry of the console server you're plugged into, there should be a series of entries like 
		<programlisting>
conserver.serial_ttyS0 minibw1:9600p:&:1h
conserver.serial_ttyS1 minibw2:9600p:&:1h
conserver.serial_cub0  heather:9600p:&:1h
conserver.serial_cub31 deadhost:9600p:&:30m
conserver.serial_cub30 anotherdead:9600p:&:1d
</programlisting>you need to put an entry for (or edit the entry for) conserver.serial_&lt;portname> the entry should consist of &lt;hostname>:&lt;portspeed>:&lt;logfilename>:&lt;mark interval>. </para><para>portspeed should be set to 9600p, logfilename should be set to <quote>&</quote> which will default to the name of the host and finally the mark interval. </para>
</listitem>
<listitem><para>Check to see if anyone is attached to a console (<command>sshconsole -w</command>) if there is you have 2 options, wait until they are finished or kill their session if you decide on the latter broadcasting a warning first might be the best approach.</para>
</listitem>
<listitem>
<para>Finally run <command>om &lt;conserverserver>.conserver run </command>which should re-build the configuration files and restart the daemon.</para>
</listitem>
</orderedlist><para>You should now be able to sshconsole onto the console.</para></sect2>
<sect2><title>Removing consoles from the server</title>
	<orderedlist numeration="arabic">
	<listitem><para>Edit the lcfg entry for the server the console is attached to.</para>
	</listitem>
	<listitem><para>Check to see if anyone is attached to a console (<command>sshconsole -w</command>) if there is you have 2 options, wait until they are finished or kill their session if you decide on the latter broadcasting a warning first might be the best approach.</para>
	</listitem>
	<listitem><para>run <command>om &lt;conserverserver>.conserver run</command> to update the configuration and restart the daemon.</para>
	</listitem>
	</orderedlist>
</sect2>
</sect1>
<sect1><title>Rebooting, shutting down and powering off.</title>
	<para>For the moment the same rules apply as for the consoles annex, do not power cycle the console server as it will issue a halt to any connected suns.</para>
</sect1>
<sect1><title>Things it doesn't do that I would like it to do.</title>
<itemizedlist>
	<listitem><para>Reread the conserver.cf file on recieving a SIGHUP to allow recnfiguration without restarting and so not kill active sessions.</para></listitem>
	<listitem><para>Integrate console with ssh or kerberos in order to provide a properly secured session</para></listitem>
	<listitem><para>integrate with PAM</para></listitem>
	<listitem><para>RFC1437 compliance would be really usefully when you absolutely have to hit the power button</para>
	</listitem>
</itemizedlist>
</sect1>
</article>
