<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><!-- this stylesheet will later on be added by lfparser automatically: -->
    
<style type="text/css">
<!--
  pre { font-family:monospace,Courier }
  pre.code { font-family:monospace,Courier;background-color:#aedbe8; }
  p.code { width:80%; alignment:center; background-color:#aedbe8; 
        border-style:none; border-width:medium; border-color:#aedbe8; 
        padding:0.1cm ; text-align:left }
-->
</style>

    <title></title></head>


  <body>
    <h1>uucpssh.org: UUCP e-mail for Linux fans</h1>

    <h4>ArticleCategory: Hardware</h4>
    SystemAdministration

    <h4>AuthorImage:[Here we need a little image from you]</h4>
    <img src="../../common/images/Guido-S.gif" alt="[Photo of the Author]" height="164" width="173"> 

    <h4>TranslationInfo:[Author + translation history. mailto: or
    http://homepage]</h4>

    <p>original in en <a href="http://main.linuxfocus.org/%7Eguido/">Guido
    Socher</a></p>

    <h4>AboutTheAuthor:[A small biography about the author]</h4>

    <p>Guido really likes UUCP e-mail because it is a solution
that integrates perfectly with a Linux computer.
    </p>

    <h4>Abstract:</h4>
In the windows world incomming mails are received via POP3 or IMAP
and outgoing mails are sent directly via SMTP. This split setup
can cause all kind of headaches especially if you are using
different ISPs all the time.
<br>
<br>
UUCP is an old protocol but it is really a clever solution to send
and receive e-mail. On top of that uucpssh.org offers some really
flexible forwarding features.


    <h4>ArticleIllustration:</h4>
    <img src="../../common/images2/illustration330.gif" alt="uucp mail" hspace="10" width="97" height="109"> 

    <h4>ArticleBody:</h4>

    <h2>Introduction</h2>
uucpssh.org offers a really good e-mail solution for Linux
users. It combines UUCP e-mail transport with the security of
SSH and offers on top of that some flexible forwarding options.

<br><br>
UUCP is very old protocol and was originally used to copy any type of files between Unix systems. Thus the name: "Unix to Unix Copy". These early computer systems were not permanently connected via a network. Instead dialup modem connections where used to exchange data in regular time intervals. UUCP is ideal
to transport things that have a "batch job" characteristic such as e-mail or news.
<br><br>
Today UUCP is no longer used for general file tranport. It is however still
very good for e-mail, especially if you are frequently on the move.
When you are connected to a wireless Lan at the air port you can
send and receive mails in exactly the same way as from your network
at home. You don't have to change a single configuration parameter.

    <h2>The technical part</h2>
Now lets see how you configure e-mail over uucp trough an SSH tunnel.
<br><br>
For those who are now wondering how to configure this under XP or 98 or ...
You need Linux. It is a solution specifically for Linux or
Unix systems in general.
<br><br>
An e-mail system in general consists of MUAs (mail user agents), the
program where you type in the mail and read it, and MTAs (mail transport
agents) also known as mail-servers. Examples of MUAs are mutt, Kmail, 
Thunderbird, etc... MTAs transport the mail from one computer to the
other. Since UUCP/SSH are a transport protocols it is clear that we
use UUCP/SSH in this solution to interconnect the MTAs. 
<br><br>
In other words we will configure a local mail server on our Linux
computer to use UUCP instead of SMTP for both incomming and outgoing
e-mail.
<br><br>
UUCP is the transport and hides the fact from the MTA that we are
not always connected to the internet. It takes care of the transporting
of mails as a batch.
<br><br>
Finally SSH is the protocol we use to encapsulate UUCP and connect to uucpssh.org.
<br><br>
To use uucpssh.org UUCP e-mail you need to own a complete domain because
the routing is done on a per domain name basis. The local MTA on your Linux
machine will then sort the mail for the different users.
<br><br>
Since uucpssh.org sorts the mails only on a per domain basis
you have full flexibility when it comes to the user part (the stuff before the "@" sign).
You can create as many aliases and users as you like. 

    <h2>What's a MX domain?</h2>
A domain name is something like linuxfocus.org, that's probably clear to most
people. To have a domain you need a DNS server. The internet works at the protocol
level not with names but with numbers, IP addresses. A DNS server translates a name
into an IP address and then this number is used to establish the connection between
to hosts (e.g web servers or mail servers). 
<br><br>
If you want to have to physically differnt hosts for web pages and ftp then you have
to give them different names. E.g linuxfocus.org and ftp.linuxfocus.org.
<br>
This is however not the case e-mail because there is a special DNS entry for mail called
MX (Mail Exchanger). You can have your webpages at one host (linuxfocus.org)
and you can have you e-mail at uucpssh.org and reach it also via linuxfocus.org (or something@linuxfocus.org).
<br><br>
In other words when you move to uucpssh.org then you move only the MX domain.

    <h2>Setting it up, MTA part</h2>
We will start with the configuration of the MTA. 
In this article we  discuss exim, postfix and sendmail. Any of them is
good for UUCP. 

    <h3>Exim 3</h3>
    Add this to the main section (at the top) of the exim.conf file: 

<pre class="code">
trusted_users = uucp
primary_hostname = your.own.mail.domain
local_domains = your.own.mail.domain
</pre>
    In the transport section add: 
<pre class="code">
# Transport for uucp
uucp:
  driver = pipe
  user = nobody
  command = "/usr/bin/uux -r - ${host}!rmail ${pipe_addresses}"
  return_fail_output = true
</pre>
    At the beginning (!) of the router section add: 
<pre class="code">
# Router for uucp (which domains are uucp domains):
# This must come before lookuphost!
uucphost:
  transport = uucp
  driver = domainlist
  route_list = * uucpssh byname
</pre>
    Test the configuration with the command exim -bV and then
    restart exim. (/etc/init.d/exim restart) 

   <h3>Exim 4</h3>

    Add to the exim.conf the following entries: 
<pre class="code">
trusted_users = uucp
primary_hostname = your.own.mail.domain
domainlist local_domains =  your.own.mail.domain
domainlist relay_to_domains =
hostlist   relay_from_hosts = 127.0.0.1
</pre>
    In the transport section add: 
<pre class="code">
# Transport for uucp
uucp:
  driver = pipe
  user = uucp
  command = "/usr/bin/uux -r - ${host}!rmail ${pipe_addresses}"
  path = /usr/local/bin:/usr/bin:/bin
  return_fail_output
</pre>
    At the beginning of the router section add: 
<pre class="code">
# Router for uucp (which domains are uucp domains):
# This must come at the beginning of the router section
uucphost:
  transport = uucp
  driver = manualroute
  domains = ! +local_domains
  route_list = * uucpssh byname
</pre>
    Test the configuration with the command exim -bV and then
    restart exim. (/etc/init.d/exim restart) 


    <h3>Sendmail</h3>

    Sendmail uses a m4 pre-processor based configuration system.
    The m4 configuration system might not be included in the same
    package as sendmail it self. Check the CDs of your distribution
    your might need to install a package called something like
    "sendmail-cf". 

    <p>Create a new sendmail-uucp.mc file in the cf directory for
    sendmail (probably /usr/lib/sendmail-cf/cf):</p>
<pre class="code">
#divert(-1)
# `This is config sends outgoing mail via uucp 
#
# to generate a sendmail.cf out of this .mc file 
# use the sendmail sources
# and run m4 thisfile.mc &gt; sendmail.cf.'
divert(0)
include(`../m4/cf.m4')
VERSIONID(`UUCP, without DNS')
undefine(`BITNET_RELAY')
undefine(`DECNET_RELAY')
undefine(`UUCP_RELAY')
OSTYPE(`linux')
MASQUERADE_AS(your.own.mail.domain)
MASQUERADE_DOMAIN(localdomain)
MASQUERADE_DOMAIN(localhost)
# ` needed if you use an internal domain that does not exist: '
FEATURE(`masquerade_envelope')
FEATURE(always_add_domain)
# ` read allowed domains from cw file: '
FEATURE(use_cw_file)
FEATURE(local_procmail)
# `important for uucp:'
FEATURE(accept_unresolvable_domains)dnl
# `the /etc/passwd entry: mail:*:8:12:mail:/var/spool/mail:'
define(`confDEF_USER_ID',``8:12'')
define(`confSAFE_QUEUE',`True')
define(`confDELIVERY_MODE',`background')dnl
# 'replace mfic by the UUCP system name of your ISP:'
define(`SMART_HOST',uucp-uudom:uucpssh)dnl
define(`confSERVICE_SWITCH_FILE',/etc/service.switch)dnl
define(`confHOSTS_FILE',/etc/hosts)dnl
define(`UUCP_MAILER_MAX',1024000)dnl
MAILER(procmail)dnl
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(uucp)dnl
</pre>
    Compile it with the command: 
<pre class="code">
m4 sendmail-uucp.mc &gt; sendmail.cf
</pre>
    Copy the sendmail.cf file to /etc and restart sendmail with 

<pre class="code">
/etc/init.d/sendmail restart
</pre>
    <br>
    In the /etc/service.switch file you should use: 
<pre class="code">
hosts   files
aliases files
</pre>

    <h3>Postfix</h3>
See also Postfix FAQ (<a href="http://www.postfix.org/faq.html#uucp-tcp">http://www.postfix.org/faq.html#uucp-tcp</a>)
on using UUCP as the default transport.

<br>
In the /etc/postfix/main.cf add:
<pre class="code">
relayhost=uucpssh
default_transport=uucp
</pre>
and in /etc/postfix/master.cf you should have the following entry:
<pre class="code">
uucp unix - n n - - pipe
  flags=F user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
</pre>

    <h2>Setting it up, UUCP part</h2>
The uucp software is available from <a href="http://www.airs.com/ian/uucp.html">http://www.airs.com/ian/uucp.html</a> however check the CDs of your linux distribution first. All major distributions
have packages for it. If you stil want to install from the source then watch out. UUCP
(at least until version 1.07) uses some rather strange path naming conventions. It installs
e.g executables to /usr/lib/uucp. All packages from the distributions have fixed those problems.
Having said that: gentoo linux installs in version 1.06 the files to the right directories (/usr/bin, /usr/sbin, /etc/uucp) but the compiled in path is still wrong in a few cases.

<br><br>I will further down describe a few tips how to debug problems with the uucp installation.

<br><br>
   <p>For the configuration of uucp you should have in the directory /etc/uucp/  at least the
    following files:</p>

    <ul>
      <li>config -- general configuration file (if all path are correctly comiled
into uucp then this file can be empty)</li>

      <li>call -- "a password file" for uucp login to uucpssh.org</li>

      <li>port -- config file for the type of connection to
      use</li>

      <li>sys -- defines all uucp systems that your system knows
      of</li>
    </ul>
In the uucp world every installation of uucp should have a name. This name is checked
when two uucp systems handshake at the beginning of their communication.
uucpssh.org is called uucpssh (all lower case) and your system name is what you define
when you create an account at uucpssh.org. In the example below it will be mailtux.

<br><br>
Edit file /etc/uucp/sys and add at the end:
<pre class="code">
system uucpssh
myname mailtux
time any
address main.uucpssh.org
port SSH
protocol t
remote-send /
remote-receive ~
chat ""
</pre>
Edit file /etc/uucp/port and add at the end:
<pre class="code">
port SSH
type pipe
command /usr/bin/ssh -C -x -o batchmode=yes uucp@main.uucpssh.org
</pre>
Edit file /etc/uucp/call and add:
<pre class="code">
uucpssh mailtux your-random-string-get-it-from-uucpssh.org-admin-page
</pre>

<br>
Now check your configuration by running the command "uuchk". Correct any syntax errors if
needed.
<br><br>
To forward mails to uucpssh.org we will use ssh as user uucp. Make sure there is a user
defined in /etc/passwd with the name uucp and that it has a valid home directory.
<br>Check also that uucico has the s-bit set and belongs to the user uucp. The program, when
executed by any user must always run as if it was executed by the user uucp. The same
is valid for uux:
<pre class="code">
-r-sr-sr-x    1 uucp     uucp  225008 Mar  7  2002 /usr/sbin/uucico
-r-sr-xr-x    1 uucp     uucp   93920 Mar  7  2002 /usr/bin/uux
</pre>
    
    <h2>Setting it up, SSH part</h2>
We must now generate a DSA key for ssh and upload it to the uucpssh.org admin page.
How to do this is also described on the admin page. I just repeat it here. 
<pre class="code">
- Become uucp user (su - uucp)
- Execute ssh-keygen -t dsa
- Do not give any password.
- upload the content of ~uucp/.ssh/id_dsa.pub to your uucpssh.org admin page
</pre>

<h2>Testing</h2>
    Send a mail to somebody outside of your host and check that it
    is queued via uucp with the command 
<pre class="code">
uustat -a

</pre>
The mail should have ended up in the /var/spool/uucp/uucpssh/C./ and /var/spool/uucp/uucpssh/D./
directories.
    Run 
<pre class="code">
uulog -40
</pre>
    to see what happened. Check the log files in /var/log for your
    mailer and /var/log/uucp for uucp. Those files can give you some clues if
    things don't work. If the above did not work then the fault is somewhere
in the configuration of your MTA (mail server).
<br>
<br>
If above test was OK then test the SSH connection. Login as user uucp (su - uucp as root) and
run. 
<pre class="code">
ssh uucp@main.uucpssh.org -v
</pre>
Accept the server's RSA key and you should see a uucp prompt (something like "Shere...").
<br>
<br>
Finally we test the sending out of our queued  uucp mail with the command:
<pre class="code">
/usr/sbin/uucico -x 11 -S uucpssh
</pre>
The -x11 adds the maximum amount of debug information. If anything goes wrong
then you should find clues in /var/log/uucp/Debug.

<br>
<br>
To test incomming mails send a mail from outside to yourUserId@your.own.mail.domain
and then fetch the mails from uucpssh.org with the command:
<pre class="code">
/usr/sbin/uucico -x 11 -S uucpssh
</pre>
Again check /var/log/uucp/Debug for problems. Incomming mails are first queued in
/var/spool/uucp/uucpssh/X./ and then automatically send to your MTA via the command
/usr/sbin/uuxqt and /usr/bin/rmail. gentoo linux had here a bug: It was looking for uuxqt 
under /usr/lib/uucp/ and was expecting the configuration files in /usr/conf/uucp. I fixed
those gentoo specific faults by creating some softlinks.
 
<br>
Check the log of your MTA and you should see that the mail was received and delivered to you.

  <h3>Daily use</h3>
    Once installed correctly there is not much to do. You just run 

<pre class="code">
/usr/sbin/uucico -S uucpssh
uulog -5
</pre>
    to exchange mail with the Internet. I prefer to have total
    control over that and I run it manually via a script but you
    can also add 
<pre class="code">
/usr/sbin/uucico -S uucpssh
</pre>
    to /etc/ppp/ip-up and it will be executed every time you connect
    to the Internet. 
<br>
  <h2>Links</h2>
<ul>
<li><a href="http://uucpssh.org">http://uucpssh.org</a>
<li><a href="http://www.xname.org/">http://www.xname.org/</a>, free DNS hosting
</ul>
<br>
Enjoy UUCP mail!


  </body></html>